Completed
Push — master ( d669e8...355804 )
by James Ekow Abaka
02:29
created
src/relationships/ManyHaveManyRelationship.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             ->filterBy($this->options['junction_local_key'], $data[$this->options['local_key']])
47 47
             ->fetch();
48 48
         $foreignKeys = [];
49
-        foreach($filter->toArray() as $foreignItem) {
49
+        foreach ($filter->toArray() as $foreignItem) {
50 50
             $foreignKeys[] = $foreignItem[$this->options['junction_foreign_key']];
51 51
         }
52 52
         $query = (new \ntentan\nibii\QueryParameters($this->getModelInstance()))
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
     public function runSetup()
58 58
     {
59
-        if(isset($this->options['through'])) {
59
+        if (isset($this->options['through'])) {
60 60
             $junctionModelName = $this->options['through'];
61 61
         } else {
62 62
             $junctionModelName = Nibii::joinModels($this->setupName, $this->options['model']);
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
         $this->options['junction_model'] = $junctionModelName;
65 65
         
66 66
         $foreignModel = Nibii::load($this->options['model']);
67
-        if($this->options['foreign_key'] == null) {
67
+        if ($this->options['foreign_key'] == null) {
68 68
             $this->options['foreign_key'] = $foreignModel->getDescription()->getPrimaryKey()[0];
69 69
         } 
70 70
         
71
-        if($this->options['local_key'] == null) {
71
+        if ($this->options['local_key'] == null) {
72 72
             $this->options['local_key'] = $this->setupPrimaryKey[0];
73 73
         }
74 74
         
75
-        if(!isset($this->options['junction_local_key'])) {
75
+        if (!isset($this->options['junction_local_key'])) {
76 76
             $this->options['junction_local_key'] = 
77
-                Text::singularize($this->setupTable) . '_id';
77
+                Text::singularize($this->setupTable).'_id';
78 78
         }
79 79
         
80
-        if(!isset($this->options['junction_foreign_key'])) {
80
+        if (!isset($this->options['junction_foreign_key'])) {
81 81
             $this->options['junction_foreign_key'] = 
82
-                Text::singularize($foreignModel->getTable()) . '_id';
82
+                Text::singularize($foreignModel->getTable()).'_id';
83 83
         }
84 84
     }
85 85
 }
Please login to merge, or discard this patch.
src/relationships/BelongsToRelationship.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
45 45
     public function runSetup()
46 46
     {
47 47
         $model = (new \ReflectionClass(Nibii::getClassName($this->options['model'], self::BELONGS_TO)))->newInstance();
48
-        if($this->options['foreign_key'] == null) {
48
+        if ($this->options['foreign_key'] == null) {
49 49
             $this->options['foreign_key'] = $model->getDescription()->getPrimaryKey()[0];
50 50
         }
51
-        if($this->options['local_key'] == null) {
52
-            $this->options['local_key'] = Text::singularize($model->getTable()) . '_id';
51
+        if ($this->options['local_key'] == null) {
52
+            $this->options['local_key'] = Text::singularize($model->getTable()).'_id';
53 53
         }
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
src/relationships/HasManyRelationship.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,10 +42,10 @@
 block discarded – undo
42 42
 
43 43
     public function runSetup()
44 44
     {
45
-        if($this->options['foreign_key'] == null) {
46
-            $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id';
45
+        if ($this->options['foreign_key'] == null) {
46
+            $this->options['foreign_key'] = Text::singularize($this->setupTable).'_id';
47 47
         }
48
-        if($this->options['local_key'] == null) {
48
+        if ($this->options['local_key'] == null) {
49 49
             $this->options['local_key'] = $this->setupPrimaryKey[0];
50 50
         }
51 51
     }
Please login to merge, or discard this patch.
src/QueryParameters.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     
81 81
     public function getSorts()
82 82
     {
83
-        return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null;
83
+        return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null;
84 84
     }
85 85
 
86 86
     public function addFilter($field, $values = [])
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
         if ($numValues === 1) {
93 93
             $key = "filter_{$startIndex}";
94
-            if($values[0] === null) {
94
+            if ($values[0] === null) {
95 95
                $this->whereClause .= "{$field} is NULL";
96 96
             } else {
97 97
                $this->whereClause .= "{$field} = :$key";
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             $this->whereClause .= "{$field} IN (";
102 102
             $comma = '';
103 103
             for ($i = 0; $i < $numValues; $i++) {
104
-                $key = "filter_" . ($startIndex + $i);
104
+                $key = "filter_".($startIndex + $i);
105 105
                 $this->whereClause .= "$comma:$key";
106 106
                 $this->boundData[$key] = $values[$i];
107 107
                 $comma = ' ,';
Please login to merge, or discard this patch.
src/validations/UniqueValidation.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
     public function run($field, $data)
46 46
     {
47 47
         $test = [];
48
-        foreach($field['name'] as $name) {
48
+        foreach ($field['name'] as $name) {
49 49
             $test[$name] = isset($data[$name]) ? $data[$name] : null;
50 50
         }
51 51
         
52
-        if($this->mode == \ntentan\nibii\DataOperations::MODE_UPDATE) {
52
+        if ($this->mode == \ntentan\nibii\DataOperations::MODE_UPDATE) {
53 53
             $primaryKeyFields = $this->model->getDescription()->getPrimaryKey();
54 54
             $keys = [];
55
-            foreach($primaryKeyFields as $name) {
55
+            foreach ($primaryKeyFields as $name) {
56 56
                 $keys[$name] = $data[$name];
57 57
             }
58 58
             $testItem = $this->model->createNew()->fetchFirst($test);
59 59
             $intersection = array_intersect($testItem->toArray(), $keys);
60
-            if(!empty($intersection)) {
60
+            if (!empty($intersection)) {
61 61
                 return true;
62 62
             }                   
63 63
         } else {
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         return $this->evaluateResult(
68 68
             $field, 
69 69
             $testItem->count() === 0,
70
-            "The value of " . implode(', ', $field['name']) . " must be unique"
70
+            "The value of ".implode(', ', $field['name'])." must be unique"
71 71
         );        
72 72
     }
73 73
 }
Please login to merge, or discard this patch.
src/FilterCompiler.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $this->getToken();
61 61
         $expression = $this->parseExpression();
62 62
         if ($this->token !== false) {
63
-            throw new FilterCompilerException("Unexpected '" . $this->token . "' in filter [$filter]");
63
+            throw new FilterCompilerException("Unexpected '".$this->token."' in filter [$filter]");
64 64
         }
65 65
         $parsed = $this->renderExpression($expression);
66 66
         return $parsed;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     private function renderExpression($expression)
70 70
     {
71 71
         if (is_array($expression)) {
72
-            $expression = $this->renderExpression($expression['left']) . " {$expression['opr']} " . $this->renderExpression($expression['right']);
72
+            $expression = $this->renderExpression($expression['left'])." {$expression['opr']} ".$this->renderExpression($expression['right']);
73 73
         }
74 74
         return $expression;
75 75
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             $tokens = [$tokens];
81 81
         }
82 82
         if (array_search($this->lookahead, $tokens) === false) {
83
-            throw new FilterCompilerException("Expected " . implode(' or ', $tokens) . " but found " . $this->lookahead);
83
+            throw new FilterCompilerException("Expected ".implode(' or ', $tokens)." but found ".$this->lookahead);
84 84
         }
85 85
     }
86 86
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
     private function returnPositionTag()
174 174
     {
175
-        return ":filter_bind_" . (++$this->numPositions);
175
+        return ":filter_bind_".(++$this->numPositions);
176 176
     }
177 177
 
178 178
     private function parseObracket()
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
             'obracket' => 'parseObracket'
196 196
         ];
197 197
 
198
-        if(isset($methods[$this->lookahead])) {
198
+        if (isset($methods[$this->lookahead])) {
199 199
             $method = $methods[$this->lookahead];
200 200
             $return = $this->$method();
201 201
         }
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         }
255 255
 
256 256
         if ($this->token === false && strlen($this->filter) > 0) {
257
-            throw new FilterCompilerException("Unexpected character [" . $this->filter[0] . "] begining " . $this->filter . ".");
257
+            throw new FilterCompilerException("Unexpected character [".$this->filter[0]."] begining ".$this->filter.".");
258 258
         }
259 259
     }
260 260
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 
268 268
     public function rewriteBoundData($data) {
269 269
         $rewritten = [];
270
-        foreach($data as $key => $value) {
271
-            if(is_numeric($key))
270
+        foreach ($data as $key => $value) {
271
+            if (is_numeric($key))
272 272
             {
273
-                $rewritten["filter_bind_" . ($key + 1)] = $value;
273
+                $rewritten["filter_bind_".($key + 1)] = $value;
274 274
             }
275 275
             else
276 276
             {
Please login to merge, or discard this patch.
src/DriverAdapter.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
     public function insert($record)
80 80
     {
81
-        if($this->insertQuery === null) {
81
+        if ($this->insertQuery === null) {
82 82
             $this->initInsert();
83 83
         }
84 84
         return Db::getDriver()->query($this->insertQuery, $record);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
     public function update($record)
88 88
     {
89
-        if($this->updateQuery === null) {
89
+        if ($this->updateQuery === null) {
90 90
             $this->initUpdate();
91 91
         }
92 92
         return Db::getDriver()->query($this->updateQuery, $record);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $driver = Db::getDefaultSettings()['driver'];
122 122
         if ($driver) {
123
-            $class = "\\ntentan\\nibii\\adapters\\" . Text::ucamelize($driver) . "Adapter";
123
+            $class = "\\ntentan\\nibii\\adapters\\".Text::ucamelize($driver)."Adapter";
124 124
             $instance = new $class();
125 125
         } else {
126 126
             throw new \Exception("No datastore specified");
Please login to merge, or discard this patch.
src/RecordWrapper.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     public function __construct()
48 48
     {
49 49
         $this->table = Nibii::getModelTable($this);
50
-        foreach($this->behaviours as $behaviour) {
50
+        foreach ($this->behaviours as $behaviour) {
51 51
             $behaviourInstance = $this->getComponentInstance($behaviour);
52 52
             $behaviourInstance->setModel($this);
53 53
         }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     protected function getDataAdapter()
61 61
     {
62
-        if(!$this->adapter)
62
+        if (!$this->adapter)
63 63
         {
64 64
             $this->adapter = DriverAdapter::getDefaultInstance();
65 65
         }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function getDescription()
74 74
     {
75 75
         return Cache::read(
76
-            (new \ReflectionClass($this))->getName() . '::desc',
76
+            (new \ReflectionClass($this))->getName().'::desc',
77 77
             function() 
78 78
             {
79 79
                 return new ModelDescription($this);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     private function retrieveItem($key)
94 94
     {
95 95
         $relationships = $this->getDescription()->getRelationships();
96
-        if(isset($relationships[$key])) {
96
+        if (isset($relationships[$key])) {
97 97
             return $this->fetchRelatedFields($relationships[$key]);
98 98
         } else {
99 99
             return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function __call($name, $arguments)
120 120
     {
121
-        if($this->dynamicOperations === null) {
121
+        if ($this->dynamicOperations === null) {
122 122
             $this->dynamicOperations = new Operations($this, $this->getDataAdapter());
123 123
         }
124 124
         return $this->dynamicOperations->perform($name, $arguments);
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     
148 148
     private function expandArrayValue($array, $relationships, $depth, $index = null)
149 149
     {
150
-        foreach($relationships as $name => $relationship) {
150
+        foreach ($relationships as $name => $relationship) {
151 151
             $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth);
152 152
         }
153 153
         return $array;
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
     {
158 158
         $relationships = $this->getDescription()->getRelationships();
159 159
         $array = $this->modelData;
160
-        if($depth > 0) {
161
-            if($this->hasMultipleData()) {
162
-                foreach($array as $i => $value) {
160
+        if ($depth > 0) {
161
+            if ($this->hasMultipleData()) {
162
+                foreach ($array as $i => $value) {
163 163
                     $array[$i] = $this->expandArrayValue($value, $relationships, $depth - 1, $i);
164 164
                 }
165 165
             } else {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 
184 184
     private function hasMultipleData()
185 185
     {
186
-        if(count($this->modelData) > 0) {
186
+        if (count($this->modelData) > 0) {
187 187
             return is_numeric(array_keys($this->modelData)[0]);
188 188
         } else {
189 189
             return false;
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
     {
195 195
         $data = [];
196 196
                 
197
-        if(count($this->modelData) == 0) {
197
+        if (count($this->modelData) == 0) {
198 198
             $data = $this->modelData;
199
-        } else if($this->hasMultipleData()) {
199
+        } else if ($this->hasMultipleData()) {
200 200
             $data = $this->modelData;
201
-        } else if(count($this->modelData) > 0) {
201
+        } else if (count($this->modelData) > 0) {
202 202
             $data[] = $this->modelData;
203 203
         }
204 204
         
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     
214 214
     public function mergeData($data)
215 215
     {
216
-        foreach($data as $key => $value) {
216
+        foreach ($data as $key => $value) {
217 217
             $this->modelData[$key] = $value;
218 218
         }
219 219
         $this->dataSet = true;
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
     private function wrap($offset)
248 248
     {
249
-        if(isset($this->modelData[$offset])) {
249
+        if (isset($this->modelData[$offset])) {
250 250
             $newInstance = $this->createNew();
251 251
             $newInstance->setData($this->modelData[$offset]);
252 252
             return $newInstance;
@@ -297,13 +297,13 @@  discard block
 block discarded – undo
297 297
 
298 298
     private function fetchRelatedFields($relationship, $index = null)
299 299
     {
300
-        if($index === null) {
300
+        if ($index === null) {
301 301
             $data = $this->modelData;
302 302
         } else {
303 303
             $data = $this->modelData[$index];
304 304
         }
305 305
         $model = $relationship->getModelInstance();
306
-        if(empty($data)) {
306
+        if (empty($data)) {
307 307
             return $model;
308 308
         } else {
309 309
             return $model->fetch($relationship->getQuery($data));
Please login to merge, or discard this patch.
src/ClassNameResolver.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 {
23 23
     public function getClassName($default, $context)
24 24
     {
25
-        if(self::$classResolver !== null && $model[0] !== "\\") {
25
+        if (self::$classResolver !== null && $model[0] !== "\\") {
26 26
             $resolver = self::$classResolver;
27 27
             $className = $resolver($model, $context);
28 28
         } else {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
         $arrayed = explode('\\', $className);
37 37
         $class = array_pop($arrayed);
38
-        if($arrayed[0] == '') {
38
+        if ($arrayed[0] == '') {
39 39
             array_shift($arrayed);
40 40
         }
41 41
         return ['class' => $class, 'namespace' => implode('\\', $arrayed)];
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         $classA = $this->getClassFileDetails($classA);
47 47
         $classB = $this->getClassFileDetails($classB);
48
-        if($classA['namespace'] != $classB['namespace']) {
48
+        if ($classA['namespace'] != $classB['namespace']) {
49 49
             throw new NibiiException(
50 50
                 "Cannot automatically join two classes of different "
51 51
                     . "namespaces. Please provide a model joiner or "
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         }
55 55
         $classes = [$classA['class'], $classB['class']];
56 56
         sort($classes);
57
-        return "{$classA['namespace']}\\" . implode('', $classes);        
57
+        return "{$classA['namespace']}\\".implode('', $classes);        
58 58
     }
59 59
 
60 60
     public function getTableName($instance)
Please login to merge, or discard this patch.