@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @method void unset(string $var) |
24 | 24 | * @method DotEnv clear() |
25 | 25 | */ |
26 | -class DotEnv{ |
|
26 | +class DotEnv { |
|
27 | 27 | use Env{ |
28 | 28 | // allow a magic getter & setter |
29 | 29 | __getEnv as public __get; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param string|null $filename |
58 | 58 | * @param bool|null $global |
59 | 59 | */ |
60 | - public function __construct(string $path, string $filename = null, bool $global = null){ |
|
60 | + public function __construct(string $path, string $filename = null, bool $global = null) { |
|
61 | 61 | $this->path = $path; |
62 | 62 | $this->filename = $filename; |
63 | 63 | $this->_global = $global ?? true; // emulate vlucas/dotenv behaviour by default |
@@ -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,12 +28,12 @@ discard block |
||
28 | 28 | * @param array $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 | |
36 | - foreach($properties as $key => $value){ |
|
36 | + foreach ($properties as $key => $value) { |
|
37 | 37 | $this->__set($key, $value); |
38 | 38 | } |
39 | 39 | |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function __get(string $property){ |
|
49 | + public function __get(string $property) { |
|
50 | 50 | |
51 | - if($this->__isset($property)){ |
|
51 | + if ($this->__isset($property)) { |
|
52 | 52 | return $this->{$property}; |
53 | 53 | } |
54 | - elseif($this->env instanceof DotEnv){ |
|
54 | + elseif ($this->env instanceof DotEnv) { |
|
55 | 55 | return $this->env->get($property); |
56 | 56 | } |
57 | 57 | |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - public function __set(string $property, $value){ |
|
67 | + public function __set(string $property, $value) { |
|
68 | 68 | |
69 | 69 | // avoid overwriting private properties |
70 | - if(!property_exists($this, $property) || !$this->__isPrivate($property)){ |
|
70 | + if (!property_exists($this, $property) || !$this->__isPrivate($property)) { |
|
71 | 71 | $this->{$property} = $value; |
72 | 72 | } |
73 | - elseif($this->env instanceof DotEnv){ |
|
73 | + elseif ($this->env instanceof DotEnv) { |
|
74 | 74 | $this->env->set($property, $value); |
75 | 75 | } |
76 | 76 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return void |
101 | 101 | */ |
102 | - public function __unset(string $property){ |
|
102 | + public function __unset(string $property) { |
|
103 | 103 | |
104 | 104 | // avoid unsetting private properties |
105 | - if($this->__isPrivate($property)){ |
|
105 | + if ($this->__isPrivate($property)) { |
|
106 | 106 | unset($this->{$property}); |
107 | 107 | } |
108 | 108 | |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | public function __toArray():array{ |
122 | 122 | $data = []; |
123 | 123 | |
124 | - foreach($this as $property => $value){ |
|
124 | + foreach ($this as $property => $value) { |
|
125 | 125 | |
126 | 126 | // exclude private properties |
127 | - if($this->__isset($property)){ |
|
127 | + if ($this->__isset($property)) { |
|
128 | 128 | $data[$property] = $value; |
129 | 129 | } |
130 | 130 |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | if($this->__isset($property)){ |
52 | 52 | return $this->{$property}; |
53 | - } |
|
54 | - elseif($this->env instanceof DotEnv){ |
|
53 | + } elseif($this->env instanceof DotEnv){ |
|
55 | 54 | return $this->env->get($property); |
56 | 55 | } |
57 | 56 | |
@@ -69,8 +68,7 @@ discard block |
||
69 | 68 | // avoid overwriting private properties |
70 | 69 | if(!property_exists($this, $property) || !$this->__isPrivate($property)){ |
71 | 70 | $this->{$property} = $value; |
72 | - } |
|
73 | - elseif($this->env instanceof DotEnv){ |
|
71 | + } elseif($this->env instanceof DotEnv){ |
|
74 | 72 | $this->env->set($property, $value); |
75 | 73 | } |
76 | 74 |