@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * a generic container with magic getter and setter |
19 | 19 | */ |
20 | -trait Container{ |
|
20 | +trait Container { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @var \chillerlan\Traits\DotEnv|null |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | * @param iterable $properties |
29 | 29 | * @param \chillerlan\Traits\DotEnv|null $env |
30 | 30 | */ |
31 | - public function __construct(array $properties = null, DotEnv $env = null){ |
|
31 | + public function __construct(array $properties = null, DotEnv $env = null) { |
|
32 | 32 | # $this->env = $env; |
33 | 33 | |
34 | - if(!empty($properties)){ |
|
34 | + if (!empty($properties)) { |
|
35 | 35 | $this->__fromIterable($properties); |
36 | 36 | } |
37 | 37 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function __get(string $property){ |
|
45 | + public function __get(string $property) { |
|
46 | 46 | |
47 | - if($this->__isset($property)){ |
|
47 | + if ($this->__isset($property)) { |
|
48 | 48 | return $this->{$property}; |
49 | 49 | } |
50 | 50 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - public function __set(string $property, $value){ |
|
64 | + public function __set(string $property, $value) { |
|
65 | 65 | |
66 | 66 | // avoid overwriting private properties |
67 | - if(property_exists($this, $property) && !$this->__isPrivate($property)){ |
|
67 | + if (property_exists($this, $property) && !$this->__isPrivate($property)) { |
|
68 | 68 | $this->{$property} = $value; |
69 | 69 | return; |
70 | 70 | } |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - public function __unset(string $property){ |
|
105 | + public function __unset(string $property) { |
|
106 | 106 | |
107 | 107 | // avoid unsetting private properties |
108 | - if($this->__isset($property)){ |
|
108 | + if ($this->__isset($property)) { |
|
109 | 109 | unset($this->{$property}); |
110 | 110 | } |
111 | 111 | |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | public function __toArray():array{ |
125 | 125 | $data = []; |
126 | 126 | |
127 | - foreach($this as $property => $value){ |
|
127 | + foreach ($this as $property => $value) { |
|
128 | 128 | |
129 | 129 | // exclude private properties |
130 | - if($this->__isset($property)){ |
|
130 | + if ($this->__isset($property)) { |
|
131 | 131 | $data[$property] = $value; |
132 | 132 | } |
133 | 133 | |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return $this |
143 | 143 | */ |
144 | - public function __fromIterable(array $properties){ |
|
144 | + public function __fromIterable(array $properties) { |
|
145 | 145 | |
146 | - foreach($properties as $key => $value){ |
|
146 | + foreach ($properties as $key => $value) { |
|
147 | 147 | $this->__set($key, $value); |
148 | 148 | } |
149 | 149 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return $this |
166 | 166 | */ |
167 | - public function __fromJSON(string $json){ |
|
167 | + public function __fromJSON(string $json) { |
|
168 | 168 | return $this->__fromIterable(json_decode($json, true)); |
169 | 169 | } |
170 | 170 |