@@ -16,16 +16,16 @@ discard block |
||
16 | 16 | |
17 | 17 | use function call_user_func, get_object_vars, json_decode, json_encode, method_exists, property_exists; |
18 | 18 | |
19 | -abstract class SettingsContainerAbstract implements SettingsContainerInterface{ |
|
19 | +abstract class SettingsContainerAbstract implements SettingsContainerInterface { |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * SettingsContainerAbstract constructor. |
23 | 23 | * |
24 | 24 | * @param iterable|null $properties |
25 | 25 | */ |
26 | - public function __construct(iterable $properties = null){ |
|
26 | + public function __construct(iterable $properties = null) { |
|
27 | 27 | |
28 | - if(!empty($properties)){ |
|
28 | + if (!empty($properties)) { |
|
29 | 29 | $this->fromIterable($properties); |
30 | 30 | } |
31 | 31 | |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | protected function construct():void{ |
42 | 42 | $traits = (new ReflectionClass($this))->getTraits(); |
43 | 43 | |
44 | - foreach($traits as $trait){ |
|
44 | + foreach ($traits as $trait) { |
|
45 | 45 | $method = $trait->getShortName(); |
46 | 46 | |
47 | - if(method_exists($this, $method)){ |
|
47 | + if (method_exists($this, $method)) { |
|
48 | 48 | call_user_func([$this, $method]); |
49 | 49 | } |
50 | 50 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @inheritdoc |
56 | 56 | */ |
57 | - public function __get(string $property){ |
|
57 | + public function __get(string $property) { |
|
58 | 58 | |
59 | - if($this->__isset($property)){ |
|
59 | + if ($this->__isset($property)) { |
|
60 | 60 | return $this->{$property}; |
61 | 61 | } |
62 | 62 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function __set(string $property, $value):void{ |
70 | 70 | |
71 | - if(!property_exists($this, $property) || $this->isPrivate($property)){ |
|
71 | + if (!property_exists($this, $property) || $this->isPrivate($property)) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
75 | - if(method_exists($this, 'set_'.$property)){ |
|
75 | + if (method_exists($this, 'set_'.$property)) { |
|
76 | 76 | $this->{'set_'.$property}($value); |
77 | 77 | |
78 | 78 | return; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function __unset(string $property):void{ |
106 | 106 | |
107 | - if($this->__isset($property)){ |
|
107 | + if ($this->__isset($property)) { |
|
108 | 108 | unset($this->{$property}); |
109 | 109 | } |
110 | 110 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function fromIterable(iterable $properties):SettingsContainerInterface{ |
131 | 131 | |
132 | - foreach($properties as $key => $value){ |
|
132 | + foreach ($properties as $key => $value) { |
|
133 | 133 | $this->__set($key, $value); |
134 | 134 | } |
135 | 135 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | $data = json_decode($json, true); // as of PHP 7.3: JSON_THROW_ON_ERROR |
152 | 152 | |
153 | - if($data === false || $data === null){ |
|
153 | + if ($data === false || $data === null) { |
|
154 | 154 | throw new Exception('error while decoding JSON'); |
155 | 155 | } |
156 | 156 |