Passed
Push — master ( 02560c...6d93bd )
by smiley
04:45
created
src/Container.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,24 +17,24 @@  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
 	 * @param iterable $properties
24 24
 	 */
25
-	public function __construct(array $properties = null){
25
+	public function __construct(array $properties = null) {
26 26
 
27
-		if(!empty($properties)){
27
+		if (!empty($properties)) {
28 28
 			$this->__fromIterable($properties);
29 29
 		}
30 30
 
31 31
 		// call a method with trait name as replacement constructor for each trait
32 32
 		$traits = (new ReflectionClass($this))->getTraits();
33 33
 
34
-		foreach($traits as $trait){
34
+		foreach ($traits as $trait) {
35 35
 			$method = $trait->getShortName();
36 36
 
37
-			if(method_exists($this, $method)){
37
+			if (method_exists($this, $method)) {
38 38
 				call_user_func([$this, $trait->getShortName()]);
39 39
 			}
40 40
 		}
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return mixed
47 47
 	 */
48
-	public function __get(string $property){
48
+	public function __get(string $property) {
49 49
 
50
-		if($this->__isset($property)){
50
+		if ($this->__isset($property)) {
51 51
 			return $this->{$property};
52 52
 		}
53 53
 
@@ -60,10 +60,10 @@  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
 			return;
69 69
 		}
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @return void
96 96
 	 */
97
-	public function __unset(string $property){
97
+	public function __unset(string $property) {
98 98
 
99 99
 		// avoid unsetting private properties
100
-		if($this->__isset($property)){
100
+		if ($this->__isset($property)) {
101 101
 			unset($this->{$property});
102 102
 		}
103 103
 
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	public function __toArray():array{
117 117
 		$data = [];
118 118
 
119
-		foreach($this as $property => $value){
119
+		foreach ($this as $property => $value) {
120 120
 
121 121
 			// exclude private properties
122
-			if($this->__isset($property)){
122
+			if ($this->__isset($property)) {
123 123
 				$data[$property] = $value;
124 124
 			}
125 125
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return $this
135 135
 	 */
136
-	public function __fromIterable(array $properties){
136
+	public function __fromIterable(array $properties) {
137 137
 
138
-		foreach($properties as $key => $value){
138
+		foreach ($properties as $key => $value) {
139 139
 			$this->__set($key, $value);
140 140
 		}
141 141
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 *
157 157
 	 * @return $this
158 158
 	 */
159
-	public function __fromJSON(string $json){
159
+	public function __fromJSON(string $json) {
160 160
 		return $this->__fromIterable(json_decode($json, true));
161 161
 	}
162 162
 
Please login to merge, or discard this patch.