diff --git a/.php_cs.dist b/.php_cs.dist index dfbe2f73..60469c8f 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,8 +1,15 @@ in('src') - ->in('tests') + ->in('./') + ->name('*.php') + ->exclude([ + 'cache', + 'logs', + 'templates', + 'vendor', + ]) + ->ignoreDotFiles(true) ; return PhpCsFixer\Config::create() diff --git a/bootstrap.php b/bootstrap.php index ea35f746..08a32cf9 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -21,73 +21,67 @@ /** * PSR-4 autoloader * - * @param string $class The fully-qualified class name. - * @return void + * @param string $class the fully-qualified class name */ -spl_autoload_register(function ($class) -{ - // project-specific namespace prefix - $prefix = 'YoutubeDownloader\\'; - - // base directory for the namespace prefix - $base_dir = __DIR__ . '/src/'; - - // does the class use the namespace prefix? - $len = strlen($prefix); - - if (strncmp($prefix, $class, $len) !== 0) - { - // no, move to the next registered autoloader - return; - } - - // get the relative class name - $relative_class = substr($class, $len); - - // replace the namespace prefix with the base directory, replace namespace - // separators with directory separators in the relative class name, append - // with .php - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; - - // if the file exists, require it - if (file_exists($file)) - { - require $file; - } +spl_autoload_register(function ($class) { + // project-specific namespace prefix + $prefix = 'YoutubeDownloader\\'; + + // base directory for the namespace prefix + $base_dir = __DIR__ . '/src/'; + + // does the class use the namespace prefix? + $len = strlen($prefix); + + if (strncmp($prefix, $class, $len) !== 0) { + // no, move to the next registered autoloader + return; + } + + // get the relative class name + $relative_class = substr($class, $len); + + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; + + // if the file exists, require it + if (file_exists($file)) { + require $file; + } }); /** * Closure to create a container class */ $container = call_user_func_array( - function($custom = 'custom') - { - // Create Container - $container = new \YoutubeDownloader\Container\SimpleContainer; + function ($custom = 'custom') { + // Create Container + $container = new \YoutubeDownloader\Container\SimpleContainer; - // Create Config - $ds = DIRECTORY_SEPARATOR; + // Create Config + $ds = DIRECTORY_SEPARATOR; - $config_dir = realpath(__DIR__) . $ds . 'config' . $ds; + $config_dir = realpath(__DIR__) . $ds . 'config' . $ds; - $config = \YoutubeDownloader\Config::createFromFiles( - $config_dir . 'default.php', - $config_dir . $custom . '.php' - ); + $config = \YoutubeDownloader\Config::createFromFiles( + $config_dir . 'default.php', + $config_dir . $custom . '.php' + ); - $service_provider = new \YoutubeDownloader\ServiceProvider($config); - $service_provider->register($container); + $service_provider = new \YoutubeDownloader\ServiceProvider($config); + $service_provider->register($container); - return $container; - }, - [getenv('CONFIG_ENV') ?: 'custom'] + return $container; + }, + [getenv('CONFIG_ENV') ?: 'custom'] ); // Show all errors on debug -if ( $container->get('config')->get('debug') === true ) -{ - error_reporting(E_ALL); - ini_set('display_errors', 1); +if ($container->get('config')->get('debug') === true) { + error_reporting(E_ALL); + ini_set('display_errors', 1); } date_default_timezone_set($container->get('config')->get('default_timezone')); diff --git a/config/default.php b/config/default.php index cc081d76..fee68b2d 100644 --- a/config/default.php +++ b/config/default.php @@ -7,7 +7,7 @@ */ return [ - /** + /* * Debug mode * WARNING: This outputs debug information while processing. * This could leak sensitive server data to the browser. @@ -18,7 +18,7 @@ */ 'debug' => false, - /** + /* * Enable the YouTube signature decipher function * WARNING: This downloads javascript code from a 3rd party server and interprets it! * This MAY harm your server, if the 3rd party server delivers malicious code! @@ -28,7 +28,7 @@ */ 'enable_youtube_decipher_signature' => false, - /** + /* * Thumbnail Image Configuration * * 0 => don't show thumbnail image @@ -37,7 +37,7 @@ */ 'ThumbnailImageMode' => 2, - /** + /* * Video Download Link Configuration * 'direct' => show only direct download link * 'proxy' => show only by proxy download link @@ -45,7 +45,7 @@ */ 'VideoLinkMode' => 'both', - /** + /* * Caching mode. If normal proxy mode won't work, this makes a copy of the file on the * webserver and downloads it from there * false => proxying works by 'streaming' the file through the server @@ -53,7 +53,7 @@ */ 'localCache' => false, - /** + /* * MP3 Download Link Configuration * * Basic method for converting Youtube Video or Audio to .mp3 @@ -76,14 +76,14 @@ 'ffmpegPath' => 'C:\Program Files (x86)\ffmpeg\ffmpeg.exe', // ffmpeg location path 'aria2Path' => 'C:\cygwin\bin\aria2c.exe', // aria2 location path, @deprecated since 0.6, to be removed in 0.7 - /** + /* * show links for install browser extensions? * * true or false */ 'showBrowserExtensions' => true, - /** + /* * Multiple IPs * * You can enable this option if you are having problems with youtube IP limit / IP ban. @@ -154,7 +154,7 @@ // add as many ips as you want (they must be available in the server conf (ex: /etc/network/interfaces fro ubuntu/debian) ], - /** + /* * Set your default timezone * * e.g. Asia/Tehran or America/New_York