mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-18 05:41:14 +02:00
cs
This commit is contained in:
@@ -29,7 +29,7 @@ class HelloCommand implements CommandInterface
|
|||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
// sometimes, there is no receiver and this is the command which
|
// sometimes, there is no receiver and this is the command which
|
||||||
// does all the work
|
// does all the work
|
||||||
$this->output->write('Hello World');
|
$this->output->write('Hello World');
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ class GermanFactory extends FactoryMethod
|
|||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ class ItalianFactory extends FactoryMethod
|
|||||||
case parent::FAST:
|
case parent::FAST:
|
||||||
return new Ferrari();
|
return new Ferrari();
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
throw new \InvalidArgumentException("$type is not a valid vehicle");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,9 @@ class Singleton
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prevent the instance from being cloned
|
* prevent the instance from being cloned
|
||||||
@@ -48,7 +50,9 @@ class Singleton
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __clone()
|
private function __clone()
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prevent from being unserialized
|
* prevent from being unserialized
|
||||||
@@ -56,5 +60,7 @@ class Singleton
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function __wakeup()
|
private function __wakeup()
|
||||||
{}
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
spl_autoload_register(function ($class) {
|
spl_autoload_register(function ($class) {
|
||||||
if (preg_match('#^DesignPatterns\\\\(.+)$#', $class, $ret)) {
|
if (preg_match('#^DesignPatterns\\\\(.+)$#', $class, $ret)) {
|
||||||
$relPath = str_replace('\\', DIRECTORY_SEPARATOR, $ret[1]);
|
$relPath = str_replace('\\', DIRECTORY_SEPARATOR, $ret[1]);
|
||||||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . $relPath . '.php';
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . $relPath . '.php';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user