Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Add more files for php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Jan 2, 2018
1 parent 02ccbc7 commit 4b9002b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 63 deletions.
11 changes: 9 additions & 2 deletions .php_cs.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in('src')
->in('tests')
->in('./')
->name('*.php')
->exclude([
'cache',
'logs',
'templates',
'vendor',
])
->ignoreDotFiles(true)
;

return PhpCsFixer\Config::create()
Expand Down
98 changes: 46 additions & 52 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
18 changes: 9 additions & 9 deletions config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

return [
/**
/*
* Debug mode
* WARNING: This outputs debug information while processing.
* This could leak sensitive server data to the browser.
Expand All @@ -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!
Expand All @@ -28,7 +28,7 @@
*/
'enable_youtube_decipher_signature' => false,

/**
/*
* Thumbnail Image Configuration
*
* 0 => don't show thumbnail image
Expand All @@ -37,23 +37,23 @@
*/
'ThumbnailImageMode' => 2,

/**
/*
* Video Download Link Configuration
* 'direct' => show only direct download link
* 'proxy' => show only by proxy download link
* 'both' => show both direct and by proxy download links
*/
'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
* true => proxying generates a temporary copy of the file on the server
*/
'localCache' => false,

/**
/*
* MP3 Download Link Configuration
*
* Basic method for converting Youtube Video or Audio to .mp3
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b9002b

Please sign in to comment.