diff --git a/classes/Config.php b/classes/Config.php index 15dc952..78dd195 100644 --- a/classes/Config.php +++ b/classes/Config.php @@ -33,7 +33,11 @@ Class Config public $convert = false; public $avconv = __DIR__.'/ffmpeg/ffmpeg'; - private function __construct() { + /** + * Config constructor + */ + private function __construct() + { $yaml = Yaml::parse(__DIR__.'/../config.yml'); foreach ($yaml as $param=>$value) { if (isset($this->$param)) { @@ -45,8 +49,13 @@ Class Config } } - public static function getInstance() { - if(is_null(self::$_instance)) { + /** + * Get singleton instance + * @return Config + */ + public static function getInstance() + { + if (is_null(self::$_instance)) { self::$_instance = new Config(); } return self::$_instance; diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 09e54dc..4f70726 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -1,10 +1,38 @@ + * @license GNU General Public License http://www.gnu.org/licenses/gpl.html + * @link http://rudloff.pro + * */ namespace Alltube\Controller; use Alltube\VideoDownload; use Alltube\Config; +/** + * Main controller + * + * PHP Version 5.3.10 + * + * @category Youtube-dl + * @package Youtubedl + * @author Pierre Rudloff + * @license GNU General Public License http://www.gnu.org/licenses/gpl.html + * @link http://rudloff.pro + * */ +class FrontController +{ -class FrontController { - static function index() { + /** + * Display index page + * @return void + */ + static function index() + { global $app; $config = Config::getInstance(); $app->render( @@ -25,7 +53,12 @@ class FrontController { $app->render('footer.tpl'); } - static function extractors() { + /** + * Display a list of extractors + * @return void + */ + static function extractors() + { global $app; $app->render( 'head.tpl', @@ -44,7 +77,12 @@ class FrontController { $app->render('footer.tpl'); } - static function video() { + /** + * Dislay information about the video + * @return void + */ + static function video() + { global $app; $config = Config::getInstance(); if (isset($_GET["url"])) { @@ -74,7 +112,8 @@ class FrontController { header("Content-Type: audio/mpeg"); passthru( '/usr/bin/rtmpdump -q -r '.escapeshellarg($video->url). - ' | '.$config->avconv.' -v quiet -i - -f mp3 -vn pipe:1' + ' | '.$config->avconv. + ' -v quiet -i - -f mp3 -vn pipe:1' ); exit; } else { @@ -93,7 +132,8 @@ class FrontController { passthru( 'curl --user-agent '.escapeshellarg($UA). ' '.escapeshellarg($video->url). - ' | '.$config->avconv.' -v quiet -i - -f mp3 -vn pipe:1' + ' | '.$config->avconv. + ' -v quiet -i - -f mp3 -vn pipe:1' ); exit; } @@ -138,7 +178,12 @@ class FrontController { } } - static function redirect() { + /** + * Redirect to video file + * @return void + */ + static function redirect() + { global $app; if (isset($_GET["url"])) { try { @@ -151,7 +196,12 @@ class FrontController { } } - static function json() { + /** + * Output JSON info about the video + * @return void + */ + static function json() + { global $app; if (isset($_GET["url"])) { $app->response->headers->set('Content-Type', 'application/json'); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 2cbd47e..75b59e9 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -25,6 +25,11 @@ use Alltube\Config; * */ class ConfigTest extends PHPUnit_Framework_TestCase { + + /** + * Test the getInstance function + * @return void + */ public function testGetInstance() { putenv('CONVERT=1');