@@ -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,12 +42,12 @@ 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 | - elseif($this->env instanceof DotEnv){ |
|
| 50 | + elseif ($this->env instanceof DotEnv) { |
|
| 51 | 51 | return $this->env->get($property); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | - public function __set(string $property, $value){ |
|
| 63 | + public function __set(string $property, $value) { |
|
| 64 | 64 | |
| 65 | 65 | // avoid overwriting private properties |
| 66 | - if(property_exists($this, $property) && !$this->__isPrivate($property)){ |
|
| 66 | + if (property_exists($this, $property) && !$this->__isPrivate($property)) { |
|
| 67 | 67 | $this->{$property} = $value; |
| 68 | 68 | } |
| 69 | - elseif($this->env instanceof DotEnv){ |
|
| 69 | + elseif ($this->env instanceof DotEnv) { |
|
| 70 | 70 | $this->env->set($property, $value); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | - public function __unset(string $property){ |
|
| 98 | + public function __unset(string $property) { |
|
| 99 | 99 | |
| 100 | 100 | // avoid unsetting private properties |
| 101 | - if($this->__isset($property)){ |
|
| 101 | + if ($this->__isset($property)) { |
|
| 102 | 102 | unset($this->{$property}); |
| 103 | 103 | } |
| 104 | 104 | |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | public function __toArray():array{ |
| 118 | 118 | $data = []; |
| 119 | 119 | |
| 120 | - foreach($this as $property => $value){ |
|
| 120 | + foreach ($this as $property => $value) { |
|
| 121 | 121 | |
| 122 | 122 | // exclude private properties |
| 123 | - if($this->__isset($property)){ |
|
| 123 | + if ($this->__isset($property)) { |
|
| 124 | 124 | $data[$property] = $value; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | * |
| 135 | 135 | * @return $this |
| 136 | 136 | */ |
| 137 | - public function __fromIterable(iterable $properties){ |
|
| 137 | + public function __fromIterable(iterable $properties) { |
|
| 138 | 138 | |
| 139 | - foreach($properties as $key => $value){ |
|
| 139 | + foreach ($properties as $key => $value) { |
|
| 140 | 140 | $this->__set($key, $value); |
| 141 | 141 | } |
| 142 | 142 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function __fromJSON(string $json){ |
|
| 158 | + public function __fromJSON(string $json) { |
|
| 159 | 159 | return $this->__fromIterable(json_decode($json, true)); |
| 160 | 160 | } |
| 161 | 161 | |