Completed
Push — master ( 61665e...00db75 )
by James Ekow Abaka
03:32
created
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/DriverAdapter.php 2 patches
Spacing   +2 added lines, -2 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);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace ntentan\nibii;
4 4
 
5
-use ntentan\utils\Text;
6 5
 use ntentan\atiaa\Db;
7 6
 
8 7
 /**
Please login to merge, or discard this patch.
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/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/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/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/RecordWrapper.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     /**
103 103
      * @method
104
-     * @param type $name
104
+     * @param string $name
105 105
      * @param type $arguments
106 106
      * @return type
107 107
      */
@@ -136,6 +136,10 @@  discard block
 block discarded – undo
136 136
         return $this->table;
137 137
     }
138 138
     
139
+    /**
140
+     * @param Relationship[] $relationships
141
+     * @param integer $depth
142
+     */
139 143
     private function expandArrayValue($array, $relationships, $depth, $index = null)
140 144
     {
141 145
         foreach($relationships as $name => $relationship) {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,6 @@
 block discarded – undo
25 25
 
26 26
 namespace ntentan\nibii;
27 27
 
28
-use ntentan\utils\Utils;
29 28
 use ntentan\kaikai\Cache;
30 29
 use ntentan\panie\InjectionContainer;
31 30
 use ntentan\utils\Text;
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     {
51 51
         $this->table = Nibii::getModelTable($this);
52 52
         $this->adapter = $adapter;
53
-        foreach($this->behaviours as $behaviour) {
53
+        foreach ($this->behaviours as $behaviour) {
54 54
             $behaviourInstance = $this->getComponentInstance($behaviour);
55 55
             $behaviourInstance->setModel($this);
56 56
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public function getDescription()
64 64
     {
65 65
         return Cache::read(
66
-            (new \ReflectionClass($this))->getName() . '::desc',
66
+            (new \ReflectionClass($this))->getName().'::desc',
67 67
             function() 
68 68
             {
69 69
                 return new ModelDescription($this);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     {
85 85
         $relationships = $this->getDescription()->getRelationships();
86 86
         $decamelizedKey = Text::deCamelize($key);
87
-        if(isset($relationships[$key])) {
87
+        if (isset($relationships[$key])) {
88 88
             return $this->fetchRelatedFields($relationships[$key]);
89 89
         }
90 90
         return isset($this->modelData[$decamelizedKey]) ? $this->modelData[$decamelizedKey] : null;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function __call($name, $arguments)
110 110
     {
111
-        if($this->dynamicOperations === null) {
111
+        if ($this->dynamicOperations === null) {
112 112
             $this->dynamicOperations = new Operations(
113 113
                 $this, $this->adapter
114 114
             );
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     
140 140
     private function expandArrayValue($array, $relationships, $depth, $index = null)
141 141
     {
142
-        foreach($relationships as $name => $relationship) {
142
+        foreach ($relationships as $name => $relationship) {
143 143
             $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth);
144 144
         }
145 145
         return $array;
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $relationships = $this->getDescription()->getRelationships();
151 151
         $array = $this->modelData;
152
-        if($depth > 0) {
153
-            if($this->hasMultipleData()) {
154
-                foreach($array as $i => $value) {
152
+        if ($depth > 0) {
153
+            if ($this->hasMultipleData()) {
154
+                foreach ($array as $i => $value) {
155 155
                     $array[$i] = $this->expandArrayValue($value, $relationships, $depth - 1, $i);
156 156
                 }
157 157
             } else {
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
     private function hasMultipleData()
172 172
     {
173
-        if(count($this->modelData) > 0) {
173
+        if (count($this->modelData) > 0) {
174 174
             return is_numeric(array_keys($this->modelData)[0]);
175 175
         } else {
176 176
             return false;
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
     {
182 182
         $data = [];
183 183
                 
184
-        if(count($this->modelData) == 0) {
184
+        if (count($this->modelData) == 0) {
185 185
             $data = $this->modelData;
186
-        } else if($this->hasMultipleData()) {
186
+        } else if ($this->hasMultipleData()) {
187 187
             $data = $this->modelData;
188
-        } else if(count($this->modelData) > 0) {
188
+        } else if (count($this->modelData) > 0) {
189 189
             $data[] = $this->modelData;
190 190
         }
191 191
         
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     
201 201
     public function mergeData($data)
202 202
     {
203
-        foreach($data as $key => $value) {
203
+        foreach ($data as $key => $value) {
204 204
             $this->modelData[$key] = $value;
205 205
         }
206 206
         $this->dataSet = true;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
     private function wrap($offset)
235 235
     {
236
-        if(isset($this->modelData[$offset])) {
236
+        if (isset($this->modelData[$offset])) {
237 237
             $newInstance = $this->createNew();
238 238
             $newInstance->setData($this->modelData[$offset]);
239 239
             return $newInstance;
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
 
290 290
     private function fetchRelatedFields($relationship, $index = null)
291 291
     {
292
-        if($index === null) {
292
+        if ($index === null) {
293 293
             $data = $this->modelData;
294 294
         } else {
295 295
             $data = $this->modelData[$index];
296 296
         }
297 297
         $model = $relationship->getModelInstance();
298
-        if(empty($data)) {
298
+        if (empty($data)) {
299 299
             return $model;
300 300
         } else {
301 301
             return $model->fetch($relationship->getQuery($data));
Please login to merge, or discard this patch.
src/Resolver.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $arrayed = explode('\\', $className);
33 33
         $class = array_pop($arrayed);
34
-        if($arrayed[0] == '') {
34
+        if ($arrayed[0] == '') {
35 35
             array_shift($arrayed);
36 36
         }
37 37
         return ['class' => $class, 'namespace' => implode('\\', $arrayed)];
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     {
42 42
         $classA = $this->getClassFileDetails($classA);
43 43
         $classB = $this->getClassFileDetails($classB);
44
-        if($classA['namespace'] != $classB['namespace']) {
44
+        if ($classA['namespace'] != $classB['namespace']) {
45 45
             throw new NibiiException(
46 46
                 "Cannot automatically join two classes of different "
47 47
                     . "namespaces. Please provide a model joiner or "
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         }
51 51
         $classes = [$classA['class'], $classB['class']];
52 52
         sort($classes);
53
-        return "{$classA['namespace']}\\" . implode('', $classes);        
53
+        return "{$classA['namespace']}\\".implode('', $classes);        
54 54
     }
55 55
 
56 56
     public function getTableName($instance)
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     public static function getDriverAdapterClassName()
64 64
     {
65 65
         $driver = Config::get('ntentan:db.driver', false);
66
-        if($driver) {
67
-            return __NAMESPACE__ . '\adapters\\' . Text::ucamelize(Config::get('ntentan:db.driver')) . 'Adapter';
66
+        if ($driver) {
67
+            return __NAMESPACE__.'\adapters\\'.Text::ucamelize(Config::get('ntentan:db.driver')).'Adapter';
68 68
         } 
69 69
         throw new NibiiException("Please specify a driver");
70 70
     }
Please login to merge, or discard this patch.
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.