@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\Repository; |
| 6 | 6 | |
| 7 | -interface RepositoryInterface |
|
| 8 | -{ |
|
| 7 | +interface RepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | public function find(int $id); |
| 10 | 10 | |
| 11 | 11 | public function save(User $user); |
@@ -72,7 +72,7 @@ |
||
| 72 | 72 | */ |
| 73 | 73 | private function validate(int $id): void |
| 74 | 74 | { |
| 75 | - if (! isset($this->data[$id])) { |
|
| 75 | + if ( ! isset($this->data[$id])) { |
|
| 76 | 76 | throw new \OutOfRangeException( |
| 77 | 77 | sprintf( |
| 78 | 78 | 'Data for ID #%d is not found.', |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\Repository; |
| 6 | 6 | |
| 7 | -class MemoryStorage |
|
| 8 | -{ |
|
| 7 | +class MemoryStorage |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private function validate(int $id): void |
| 74 | 74 | { |
| 75 | - if (! isset($this->data[$id])) { |
|
| 75 | + if (! isset($this->data[$id])) {
|
|
| 76 | 76 | throw new \OutOfRangeException( |
| 77 | 77 | sprintf( |
| 78 | 78 | 'Data for ID #%d is not found.', |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\ServiceLocator; |
| 6 | 6 | |
| 7 | -interface ServiceInterface |
|
| 8 | -{ |
|
| 7 | +interface ServiceInterface |
|
| 8 | +{
|
|
| 9 | 9 | } |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\ServiceLocator; |
| 6 | 6 | |
| 7 | -class ServiceLocator |
|
| 8 | -{ |
|
| 7 | +class ServiceLocator |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @throws \OutOfRangeException |
| 80 | 80 | */ |
| 81 | - public function get(string $class) |
|
| 82 | - { |
|
| 83 | - if (isset($this->instantiated[$class]) && $this->shared[$class]) { |
|
| 81 | + public function get(string $class) |
|
| 82 | + {
|
|
| 83 | + if (isset($this->instantiated[$class]) && $this->shared[$class]) {
|
|
| 84 | 84 | return $this->instantiated[$class]; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $object = $this->getInstance($class); |
| 88 | 88 | |
| 89 | - if ($this->shared[$class]) { |
|
| 89 | + if ($this->shared[$class]) {
|
|
| 90 | 90 | $this->instantiated[$class] = $object; |
| 91 | 91 | } |
| 92 | 92 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | private function getInstance(string $class): ServiceInterface |
| 106 | 106 | { |
| 107 | 107 | $args = $this->services[$class]; |
| 108 | - switch (\count($args)) { |
|
| 108 | + switch (\count($args)) {
|
|
| 109 | 109 | case 0: |
| 110 | 110 | $object = new $class(); |
| 111 | 111 | break; |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\ServiceLocator; |
| 6 | 6 | |
| 7 | -class ResponseService implements ServiceInterface |
|
| 8 | -{ |
|
| 7 | +class ResponseService implements ServiceInterface |
|
| 8 | +{
|
|
| 9 | 9 | } |
@@ -4,6 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\ServiceLocator; |
| 6 | 6 | |
| 7 | -class RequestService implements ServiceInterface |
|
| 8 | -{ |
|
| 7 | +class RequestService implements ServiceInterface |
|
| 8 | +{
|
|
| 9 | 9 | } |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\Delegation; |
| 6 | 6 | |
| 7 | -class Component |
|
| 8 | -{ |
|
| 7 | +class Component |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * String to array. |
| 11 | 11 | * |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Creational\SimpleFactory; |
| 6 | 6 | |
| 7 | -class Swift implements LanguageInterface |
|
| 8 | -{ |
|
| 7 | +class Swift implements LanguageInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * Swift language write application. |
| 11 | 11 | * |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | public function create(string $language): LanguageInterface |
| 35 | 35 | { |
| 36 | - if (! array_key_exists($language, $this->language)) { |
|
| 36 | + if ( ! array_key_exists($language, $this->language)) { |
|
| 37 | 37 | throw new \InvalidArgumentException("$language is not valid programming language."); |
| 38 | 38 | } |
| 39 | 39 | $class = $this->language[$language]; |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\Creational\SimpleFactory; |
| 6 | 6 | |
| 7 | -class SimpleFactory |
|
| 8 | -{ |
|
| 7 | +class SimpleFactory |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * SimpleFactory constructor. |
| 16 | 16 | */ |
| 17 | - public function __construct() |
|
| 18 | - { |
|
| 17 | + public function __construct() |
|
| 18 | + {
|
|
| 19 | 19 | $this->language = [ |
| 20 | 20 | 'java' => __NAMESPACE__ . '\\Java', |
| 21 | 21 | 'swift' => __NAMESPACE__ . '\\Swift', |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function create(string $language): LanguageInterface |
| 35 | 35 | { |
| 36 | - if (! array_key_exists($language, $this->language)) { |
|
| 36 | + if (! array_key_exists($language, $this->language)) {
|
|
| 37 | 37 | throw new \InvalidArgumentException("$language is not valid programming language."); |
| 38 | 38 | } |
| 39 | 39 | $class = $this->language[$language]; |