From 532b3c27a3a8cc9611dfc7b9321126411de37f8c Mon Sep 17 00:00:00 2001 From: siad007 Date: Thu, 7 Aug 2014 00:06:17 +0200 Subject: [PATCH] Added static calls --- .gitignore | 3 ++- src/Factory.php | 30 ++++++++++++++++++++++++++++++ tests/Command/CloneCommandTest.php | 6 ++---- tests/Command/HeadsCommandTest.php | 3 +-- tests/Command/InitCommandTest.php | 3 +-- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 19a00fa..8f4c2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ composer.phar box.phar phpunit.xml test.php -composer.lock \ No newline at end of file +composer.lock +.pydevproject \ No newline at end of file diff --git a/src/Factory.php b/src/Factory.php index 901f5da..d5af4a0 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -39,6 +39,36 @@ public static function getInstance($command, $options = array()) return new $commandClassName($options); } + /** + * @param array $options + * + * @return \Siad007\VersionControl\HG\Command\CloneCommand + */ + public static function createClone($options = array()) + { + return self::getInstance('clone', $options); + } + + /** + * @param array $options + * + * @return \Siad007\VersionControl\HG\Command\HeadsCommand + */ + public static function createHeads($options = array()) + { + return self::getInstance('heads', $options); + } + + /** + * @param array $options + * + * @return \Siad007\VersionControl\HG\Command\InitCommand + */ + public static function createInit($options = array()) + { + return self::getInstance('init', $options); + } + /** * Disabled clone behavior. */ diff --git a/tests/Command/CloneCommandTest.php b/tests/Command/CloneCommandTest.php index 4b24e46..467c3b5 100644 --- a/tests/Command/CloneCommandTest.php +++ b/tests/Command/CloneCommandTest.php @@ -11,8 +11,7 @@ class CloneCommandTest extends \PHPUnit_Framework_TestCase */ public function cloneCommand() { - /* @var $cloneCmd \Siad007\VersionControl\HG\Command\CloneCommand */ - $cloneCmd = Factory::getInstance('clone'); + $cloneCmd = Factory::createClone(); $cloneCmd->setSource('C:\\xampp\\source'); $cloneCmd->setDestination('C:\\xampp\\dest'); $cloneCmd->setUncompressed(true); @@ -32,8 +31,7 @@ public function cloneCommand() */ public function cloneCommandWithoutDestination() { - /* @var $cloneCmd \Siad007\VersionControl\HG\Command\CloneCommand */ - $cloneCmd = Factory::getInstance('clone'); + $cloneCmd = Factory::createClone(); $cloneCmd->setSource('C:\\xampp\\source'); $cloneCmd->setUncompressed(true); $cloneCmd->setInsecure(true); diff --git a/tests/Command/HeadsCommandTest.php b/tests/Command/HeadsCommandTest.php index 66ce757..9b88478 100644 --- a/tests/Command/HeadsCommandTest.php +++ b/tests/Command/HeadsCommandTest.php @@ -11,8 +11,7 @@ class HeadsCommandTest extends \PHPUnit_Framework_TestCase */ public function headsCommand() { - /* @var $headsCmd \Siad007\VersionControl\HG\Command\HeadsCommand */ - $headsCmd = Factory::getInstance('heads'); + $headsCmd = Factory::createHeads(); $headsCmd->setTemplate('template'); $headsCmd->setClosed(true); $headsCmd->setRev('startrev'); diff --git a/tests/Command/InitCommandTest.php b/tests/Command/InitCommandTest.php index f63a352..e896ae8 100644 --- a/tests/Command/InitCommandTest.php +++ b/tests/Command/InitCommandTest.php @@ -11,8 +11,7 @@ class InitCommandTest extends \PHPUnit_Framework_TestCase */ public function initCommand() { - /* @var $initCmd \Siad007\VersionControl\HG\Command\InitCommand */ - $initCmd = Factory::getInstance('init'); + $initCmd = Factory::createInit(); $initCmd->setDestination('C:\\xampp\\dest\\'); $initCmd->setSsh('testSSH'); $initCmd->setInsecure(true);