Completed
Push — master ( 73b6ea...6deb59 )
by James Ekow Abaka
02:32
created
src/ModelValidator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@  discard block
 block discarded – undo
15 15
         $this->model = $model;
16 16
         $description = $model->getDescription();
17 17
 
18
-        if($description->getAutoPrimaryKey()) {
18
+        if ($description->getAutoPrimaryKey()) {
19 19
             $pk = $description->getPrimaryKey()[0];
20 20
         }
21 21
 
22 22
         $fields = $description->getFields();
23
-        foreach($fields as $field) {
23
+        foreach ($fields as $field) {
24 24
             $this->getFieldRules($rules, $field, $pk);
25 25
         }
26 26
         
27 27
         $unique = $description->getUniqueKeys();
28
-        foreach($unique as $constraints) {
28
+        foreach ($unique as $constraints) {
29 29
             $rules['unique'][] = [$constraints['fields']];
30 30
         }
31 31
         
@@ -39,10 +39,10 @@  discard block
 block discarded – undo
39 39
 
40 40
     private function getFieldRules(&$rules, $field, $pk)
41 41
     {
42
-        if($field['required'] && $field['name'] != $pk && $field['default'] === null) {
42
+        if ($field['required'] && $field['name'] != $pk && $field['default'] === null) {
43 43
             $rules['required'][] = $field['name'];
44 44
         }
45
-        if($field['type'] === 'integer' || $field['type'] === 'double') {
45
+        if ($field['type'] === 'integer' || $field['type'] === 'double') {
46 46
             $rules['numeric'][] = $field['name'];
47 47
         }
48 48
     }
Please login to merge, or discard this patch.
src/adapters/MysqlAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
 {
6 6
     public function mapDataTypes($nativeType)
7 7
     {
8
-        switch($nativeType)
8
+        switch ($nativeType)
9 9
         {
10 10
             case 'int':
11 11
                 return 'integer';
Please login to merge, or discard this patch.
src/adapters/PostgresqlAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      */
13 13
     public function mapDataTypes($nativeType) 
14 14
     {
15
-        switch($nativeType)
15
+        switch ($nativeType)
16 16
         {
17 17
             case 'character varying':
18 18
                 return 'string';
Please login to merge, or discard this patch.
src/behaviours/TimestampableBehaviour.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
     
17 17
     public function preSaveCallback($data)
18 18
     {
19
-        if(isset($this->model->getDescription()->getFields()['created']))
19
+        if (isset($this->model->getDescription()->getFields()['created']))
20 20
         {
21 21
             $data['created'] = date('Y-m-d H:i:s');
22 22
         }
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     
26 26
     public function preUpdateCallback($data)
27 27
     {
28
-        if(isset($this->model->getDescription()->getFields()['updated']))
28
+        if (isset($this->model->getDescription()->getFields()['updated']))
29 29
         {
30 30
             $data['updated'] = date('Y-m-d H:i:s');
31 31
         }
Please login to merge, or discard this patch.
src/interfaces/TableNameResolverInterface.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -9,5 +9,8 @@
 block discarded – undo
9 9
  */
10 10
 interface TableNameResolverInterface
11 11
 {
12
+    /**
13
+     * @return string
14
+     */
12 15
     public function getTableName($instance);
13 16
 }
Please login to merge, or discard this patch.
src/interfaces/ModelJoinerInterface.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -9,5 +9,8 @@
 block discarded – undo
9 9
  */
10 10
 interface ModelJoinerInterface
11 11
 {
12
+    /**
13
+     * @return string
14
+     */
12 15
     public function getJunctionClassName($classA, $classB);
13 16
 }
Please login to merge, or discard this patch.
src/Resolver.php 2 patches
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@
 block discarded – undo
8 8
 
9 9
 namespace ntentan\nibii;
10 10
 
11
+use ntentan\config\Config;
11 12
 use ntentan\nibii\interfaces\ModelClassResolverInterface;
12 13
 use ntentan\nibii\interfaces\ModelJoinerInterface;
13 14
 use ntentan\nibii\interfaces\TableNameResolverInterface;
14
-use ntentan\config\Config;
15 15
 use ntentan\utils\Text;
16 16
 
17 17
 /**
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         }
41 41
         $classes = [$classA['class'], $classB['class']];
42 42
         sort($classes);
43
-        return "{$classA['namespace']}\\" . implode('', $classes);
43
+        return "{$classA['namespace']}\\".implode('', $classes);
44 44
     }
45 45
 
46 46
     public function getTableName($instance) {
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public static function getDriverAdapterClassName() {
53 53
         $driver = Config::get('ntentan:db.driver', false);
54 54
         if ($driver) {
55
-            return __NAMESPACE__ . '\adapters\\' . Text::ucamelize(Config::get('ntentan:db.driver')) . 'Adapter';
55
+            return __NAMESPACE__.'\adapters\\'.Text::ucamelize(Config::get('ntentan:db.driver')).'Adapter';
56 56
         }
57 57
         throw new NibiiException("Please specify a driver");
58 58
     }
Please login to merge, or discard this patch.
src/DataOperations.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -227,6 +227,9 @@
 block discarded – undo
227 227
         }
228 228
     }
229 229
 
230
+    /**
231
+     * @param string $event
232
+     */
230 233
     private function runBehaviours($event, $args) {
231 234
         foreach ($this->wrapper->getBehaviours() as $behaviour) {
232 235
             $args[0] = call_user_func_array([$behaviour, $event], $args);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
         $relationships = $this->wrapper->getDescription()->getRelationships();
157 157
         $presentRelationships = [];
158 158
         
159
-        foreach($relationships ?? [] as $model => $relationship) {
160
-            if(isset($record[$model])) {
159
+        foreach ($relationships ?? [] as $model => $relationship) {
160
+            if (isset($record[$model])) {
161 161
                 $relationship->preSave($record, $record[$model]);
162 162
                 $presentRelationships[$model] = $relationship;
163 163
             }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         
182 182
         // Reset the data so it contains any modifications made by callbacks
183 183
         $record = $this->wrapper->getData()[0];
184
-        foreach($presentRelationships as $model => $relationship) {
184
+        foreach ($presentRelationships as $model => $relationship) {
185 185
             $relationship->postSave($record);
186 186
         }        
187 187
 
Please login to merge, or discard this patch.
src/FilterCompiler.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -190,6 +190,10 @@
 block discarded – undo
190 190
         return $return;
191 191
     }
192 192
 
193
+    /**
194
+     * @param integer $level
195
+     * @param string $opr
196
+     */
193 197
     private function parseRightExpression($level, $opr) {
194 198
         switch ($opr) {
195 199
             case 'between': return $this->parseBetween();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $this->getToken();
58 58
         $expression = $this->parseExpression();
59 59
         if ($this->token !== false) {
60
-            throw new FilterCompilerException("Unexpected '" . $this->token . "' in filter [$filter]");
60
+            throw new FilterCompilerException("Unexpected '".$this->token."' in filter [$filter]");
61 61
         }
62 62
         $parsed = $this->renderExpression($expression);
63 63
         return $parsed;
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
     private function renderExpression($expression) {
67 67
         if (is_array($expression)) {
68
-            $expression = $this->renderExpression($expression['left']) . " {$expression['opr']} " . $this->renderExpression($expression['right']);
68
+            $expression = $this->renderExpression($expression['left'])." {$expression['opr']} ".$this->renderExpression($expression['right']);
69 69
         }
70 70
         return $expression;
71 71
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             $tokens = [$tokens];
76 76
         }
77 77
         if (array_search($this->lookahead, $tokens) === false) {
78
-            throw new FilterCompilerException("Expected " . implode(' or ', $tokens) . " but found " . $this->lookahead);
78
+            throw new FilterCompilerException("Expected ".implode(' or ', $tokens)." but found ".$this->lookahead);
79 79
         }
80 80
     }
81 81
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     }
161 161
 
162 162
     private function returnPositionTag() {
163
-        return ":filter_bind_" . ( ++$this->numPositions);
163
+        return ":filter_bind_".( ++$this->numPositions);
164 164
     }
165 165
 
166 166
     private function parseObracket() {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         }
238 238
 
239 239
         if ($this->token === false && strlen($this->filter) > 0) {
240
-            throw new FilterCompilerException("Unexpected character [" . $this->filter[0] . "] begining " . $this->filter . ".");
240
+            throw new FilterCompilerException("Unexpected character [".$this->filter[0]."] begining ".$this->filter.".");
241 241
         }
242 242
     }
243 243
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $rewritten = [];
252 252
         foreach ($data as $key => $value) {
253 253
             if (is_numeric($key)) {
254
-                $rewritten["filter_bind_" . ($key + 1)] = $value;
254
+                $rewritten["filter_bind_".($key + 1)] = $value;
255 255
             } else {
256 256
                 $rewritten[$key] = $value;
257 257
             }
Please login to merge, or discard this patch.