@@ -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); |
@@ -4,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\Repository; |
| 6 | 6 | |
| 7 | -class User |
|
| 8 | -{ |
|
| 7 | +class User |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var int|null |
| 11 | 11 | */ |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @param string $username |
| 29 | 29 | * @param string $email |
| 30 | 30 | */ |
| 31 | - public function __construct(int $id, string $username, string $email) |
|
| 32 | - { |
|
| 31 | + public function __construct(int $id, string $username, string $email) |
|
| 32 | + {
|
|
| 33 | 33 | $this->id = $id; |
| 34 | 34 | $this->username = $username; |
| 35 | 35 | $this->email = $email; |
@@ -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,8 +4,8 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\Repository; |
| 6 | 6 | |
| 7 | -class UserRepository implements RepositoryInterface |
|
| 8 | -{ |
|
| 7 | +class UserRepository implements RepositoryInterface |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\More\Repository\MemoryStorage |
| 11 | 11 | */ |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param \DesignPattern\More\Repository\MemoryStorage $storage |
| 18 | 18 | */ |
| 19 | - public function __construct(MemoryStorage $storage) |
|
| 20 | - { |
|
| 19 | + public function __construct(MemoryStorage $storage) |
|
| 20 | + {
|
|
| 21 | 21 | $this->storage = $storage; |
| 22 | 22 | } |
| 23 | 23 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $array = $this->storage->read($id); |
| 36 | 36 | |
| 37 | - if ($array === null) { |
|
| 37 | + if ($array === null) {
|
|
| 38 | 38 | $message = sprintf('User with ID #%d does not exist.', $id); |
| 39 | 39 | throw new \InvalidArgumentException($message); |
| 40 | 40 | } |
@@ -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 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | namespace DesignPattern\More\EntityAttributeValue; |
| 6 | 6 | |
| 7 | -class Value |
|
| 8 | -{ |
|
| 7 | +class Value |
|
| 8 | +{
|
|
| 9 | 9 | /** |
| 10 | 10 | * @var \DesignPattern\More\EntityAttributeValue\Attribute |
| 11 | 11 | */ |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | * @param \DesignPattern\More\EntityAttributeValue\Attribute $attribute |
| 23 | 23 | * @param string $name |
| 24 | 24 | */ |
| 25 | - public function __construct(Attribute $attribute, string $name) |
|
| 26 | - { |
|
| 25 | + public function __construct(Attribute $attribute, string $name) |
|
| 26 | + {
|
|
| 27 | 27 | $this->attribute = $attribute; |
| 28 | 28 | $this->name = $name; |
| 29 | 29 | |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function __toString() |
|
| 37 | - { |
|
| 36 | + public function __toString() |
|
| 37 | + {
|
|
| 38 | 38 | return sprintf('%s: %s', $this->attribute, $this->name); |
| 39 | 39 | } |
| 40 | 40 | } |