Completed
Push — master ( 6bb3cd...396d48 )
by James Ekow Abaka
03:46
created
src/RecordWrapper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 return Nibii::getModelTable($this);
53 53
             }
54 54
         );
55
-        foreach($this->behaviours as $behaviour) {
55
+        foreach ($this->behaviours as $behaviour) {
56 56
             $behaviourInstance = $this->loadDependency($behaviour);
57 57
             $behaviourInstance->setModel($this);
58 58
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     protected function getDataAdapter()
66 66
     {
67
-        if(!$this->adapter)
67
+        if (!$this->adapter)
68 68
         {
69 69
             $this->adapter = DriverAdapter::getDefaultInstance();
70 70
         }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function getDescription()
79 79
     {
80 80
         return Cache::read(
81
-            (new \ReflectionClass($this))->getName() . '::desc',
81
+            (new \ReflectionClass($this))->getName().'::desc',
82 82
             function() 
83 83
             {
84 84
                 return new ModelDescription($this);
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     private function retrieveItem($key)
99 99
     {
100 100
         $relationships = $this->getDescription()->getRelationships();
101
-        if(isset($relationships[$key])) {
101
+        if (isset($relationships[$key])) {
102 102
             return $this->fetchRelatedFields($relationships[$key]);
103 103
         } else {
104 104
             return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     
154 154
     private function expandArrayValue($array, $relationships, $depth, $index = null)
155 155
     {
156
-        foreach($relationships as $name => $relationship) {
156
+        foreach ($relationships as $name => $relationship) {
157 157
             $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth);
158 158
         }
159 159
         return $array;
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
     {
164 164
         $relationships = $this->getDescription()->getRelationships();
165 165
         $array = $this->modelData;
166
-        if($depth > 0) {
167
-            if($this->hasMultipleData()) {
168
-                foreach($array as $i => $value) {
166
+        if ($depth > 0) {
167
+            if ($this->hasMultipleData()) {
168
+                foreach ($array as $i => $value) {
169 169
                     $array[$i] = $this->expandArrayValue($value, $relationships, $depth - 1, $i);
170 170
                 }
171 171
             } else {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     private function hasMultipleData()
191 191
     {
192
-        if(count($this->modelData) > 0) {
192
+        if (count($this->modelData) > 0) {
193 193
             return is_numeric(array_keys($this->modelData)[0]);
194 194
         } else {
195 195
             return false;
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
     {
201 201
         $data = [];
202 202
                 
203
-        if(count($this->modelData) == 0) {
203
+        if (count($this->modelData) == 0) {
204 204
             $data = $this->modelData;
205
-        } else if($this->hasMultipleData()) {
205
+        } else if ($this->hasMultipleData()) {
206 206
             $data = $this->modelData;
207
-        } else if(count($this->modelData) > 0) {
207
+        } else if (count($this->modelData) > 0) {
208 208
             $data[] = $this->modelData;
209 209
         }
210 210
         
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     
220 220
     public function mergeData($data)
221 221
     {
222
-        foreach($data as $key => $value) {
222
+        foreach ($data as $key => $value) {
223 223
             $this->modelData[$key] = $value;
224 224
         }
225 225
         $this->dataSet = true;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
     private function wrap($offset)
254 254
     {
255
-        if(isset($this->modelData[$offset])) {
255
+        if (isset($this->modelData[$offset])) {
256 256
             $newInstance = $this->createNew();
257 257
             $newInstance->setData($this->modelData[$offset]);
258 258
             return $newInstance;
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 
304 304
     private function fetchRelatedFields($relationship, $index = null)
305 305
     {
306
-        if($index === null) {
306
+        if ($index === null) {
307 307
             $data = $this->modelData;
308 308
         } else {
309 309
             $data = $this->modelData[$index];
310 310
         }
311 311
         $model = $relationship->getModelInstance();
312
-        if(empty($data)) {
312
+        if (empty($data)) {
313 313
             return $model;
314 314
         } else {
315 315
             return $model->fetch($relationship->getQuery($data));
Please login to merge, or discard this patch.