@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * a generic container with magic getter and setter |
| 19 | 19 | */ |
| 20 | -interface SettingsContainerInterface extends JsonSerializable{ |
|
| 20 | +interface SettingsContainerInterface extends JsonSerializable { |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Retrieve the value of $property |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | use function call_user_func, call_user_func_array, get_object_vars, json_decode, json_encode, method_exists, property_exists; |
| 16 | 16 | use const JSON_THROW_ON_ERROR; |
| 17 | 17 | |
| 18 | -abstract class SettingsContainerAbstract implements SettingsContainerInterface{ |
|
| 18 | +abstract class SettingsContainerAbstract implements SettingsContainerInterface { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * SettingsContainerAbstract constructor. |
| 22 | 22 | */ |
| 23 | - public function __construct(iterable $properties = null){ |
|
| 23 | + public function __construct(iterable $properties = null) { |
|
| 24 | 24 | |
| 25 | - if(!empty($properties)){ |
|
| 25 | + if (!empty($properties)) { |
|
| 26 | 26 | $this->fromIterable($properties); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | protected function construct():void{ |
| 37 | 37 | $traits = (new ReflectionClass($this))->getTraits(); |
| 38 | 38 | |
| 39 | - foreach($traits as $trait){ |
|
| 39 | + foreach ($traits as $trait) { |
|
| 40 | 40 | $method = $trait->getShortName(); |
| 41 | 41 | |
| 42 | - if(method_exists($this, $method)){ |
|
| 42 | + if (method_exists($this, $method)) { |
|
| 43 | 43 | call_user_func([$this, $method]); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @inheritdoc |
| 51 | 51 | */ |
| 52 | - public function __get(string $property){ |
|
| 52 | + public function __get(string $property) { |
|
| 53 | 53 | |
| 54 | - if(!property_exists($this, $property) || $this->isPrivate($property)){ |
|
| 54 | + if (!property_exists($this, $property) || $this->isPrivate($property)) { |
|
| 55 | 55 | return null; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $method = 'get_'.$property; |
| 59 | 59 | |
| 60 | - if(method_exists($this, $method)){ |
|
| 60 | + if (method_exists($this, $method)) { |
|
| 61 | 61 | return call_user_func([$this, $method]); |
| 62 | 62 | } |
| 63 | 63 | |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function __set(string $property, $value):void{ |
| 71 | 71 | |
| 72 | - if(!property_exists($this, $property) || $this->isPrivate($property)){ |
|
| 72 | + if (!property_exists($this, $property) || $this->isPrivate($property)) { |
|
| 73 | 73 | return; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $method = 'set_'.$property; |
| 77 | 77 | |
| 78 | - if(method_exists($this, $method)){ |
|
| 78 | + if (method_exists($this, $method)) { |
|
| 79 | 79 | call_user_func_array([$this, $method], [$value]); |
| 80 | 80 | |
| 81 | 81 | return; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function __unset(string $property):void{ |
| 109 | 109 | |
| 110 | - if($this->__isset($property)){ |
|
| 110 | + if ($this->__isset($property)) { |
|
| 111 | 111 | unset($this->{$property}); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | public function fromIterable(iterable $properties):SettingsContainerInterface{ |
| 134 | 134 | |
| 135 | - foreach($properties as $key => $value){ |
|
| 135 | + foreach ($properties as $key => $value) { |
|
| 136 | 136 | $this->__set($key, $value); |
| 137 | 137 | } |
| 138 | 138 | |