Completed
Push — master ( 011d2b...b85915 )
by smiley
01:51
created
src/Container.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
134 134
 	 *
135 135
 	 * @return $this
136 136
 	 */
137
-	public function __fromIterable(array $properties){
137
+	public function __fromIterable(array $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
 block discarded – undo
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
 
Please login to merge, or discard this patch.