Completed
Push — master ( 59db5b...ed6a4c )
by James Ekow Abaka
03:47
created
src/validations/UniqueValidation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
         }
69 69
 
70 70
         return $this->evaluateResult(
71
-                        $field, $testItem->count() === 0, "The value of " . implode(', ', $field['name']) . " must be unique"
71
+                        $field, $testItem->count() === 0, "The value of ".implode(', ', $field['name'])." must be unique"
72 72
         );
73 73
     }
74 74
 
Please login to merge, or discard this patch.
src/RecordWrapper.php 3 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
     /**
133 133
      * @method
134
-     * @param type $name
134
+     * @param string $name
135 135
      * @param type $arguments
136 136
      * @return type
137 137
      */
@@ -160,6 +160,10 @@  discard block
 block discarded – undo
160 160
         return $this->retrieveItem($name);
161 161
     }
162 162
 
163
+    /**
164
+     * @param Relationship[] $relationships
165
+     * @param integer $depth
166
+     */
163 167
     private function expandArrayValue($array, $relationships, $depth, $index = null) {
164 168
         foreach ($relationships as $name => $relationship) {
165 169
             $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth);
@@ -319,6 +323,9 @@  discard block
 block discarded – undo
319 323
         
320 324
     }
321 325
 
326
+    /**
327
+     * @param string $id
328
+     */
322 329
     public function postSaveCallback($id) {
323 330
         
324 331
     }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
     private $initialized = false;
59 59
 
60 60
     public function initialize() {
61
-        if($this->initialized) return;
61
+        if ($this->initialized) return;
62 62
         $this->context = ORMContext::getInstance();
63 63
         $this->container = $this->context->getContainer();
64 64
         $this->adapter = $this->container->resolve(DriverAdapter::class);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@
 block discarded – undo
58 58
     private $initialized = false;
59 59
 
60 60
     public function initialize() {
61
-        if($this->initialized) return;
61
+        if($this->initialized) {
62
+            return;
63
+        }
62 64
         $this->context = ORMContext::getInstance();
63 65
         $this->container = $this->context->getContainer();
64 66
         $this->adapter = $this->container->resolve(DriverAdapter::class);
Please login to merge, or discard this patch.
src/relationships/BelongsToRelationship.php 2 patches
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
 
27 27
 namespace ntentan\nibii\relationships;
28 28
 
29
-use ntentan\utils\Text;
30 29
 use ntentan\nibii\ORMContext;
30
+use ntentan\utils\Text;
31 31
 
32 32
 class BelongsToRelationship extends \ntentan\nibii\Relationship {
33 33
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
     public function prepareQuery($data) {
42 42
         // @todo throw an exception when the data doesn't have the local key
43 43
         $query = $this->getQuery();
44
-        if($this->queryPrepared){
44
+        if ($this->queryPrepared) {
45 45
             $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]);
46 46
         } else {
47 47
             $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table'])
Please login to merge, or discard this patch.
src/Relationship.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     }
61 61
     
62 62
     public function getQuery() {
63
-        if(!$this->query) {
63
+        if (!$this->query) {
64 64
             $this->query = new QueryParameters();
65 65
         }
66 66
         return $this->query;
Please login to merge, or discard this patch.
src/QueryParameters.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
     }
68 68
 
69 69
     public function getWhereClause() {
70
-        if($this->whereClause) {
71
-            foreach($this->boundArrays as $boundArray) {
70
+        if ($this->whereClause) {
71
+            foreach ($this->boundArrays as $boundArray) {
72 72
                 $where = "";
73 73
                 $comma = "";
74
-                for($i = 0; $i < count($this->boundData[$boundArray]); $i++) {
74
+                for ($i = 0; $i < count($this->boundData[$boundArray]); $i++) {
75 75
                     $where .= "{$comma}:{$boundArray}_{$i}";
76 76
                     $comma = ', ';
77 77
                 }
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     public function getBoundData() {
85
-        if($this->preparedBoundData === false) {
85
+        if ($this->preparedBoundData === false) {
86 86
             $this->preparedBoundData = [];
87
-            foreach($this->boundData as $key => $value) {
88
-                if(in_array($key, $this->boundArrays)) {
89
-                    foreach($value as $i => $v) {
87
+            foreach ($this->boundData as $key => $value) {
88
+                if (in_array($key, $this->boundArrays)) {
89
+                    foreach ($value as $i => $v) {
90 90
                         $this->preparedBoundData["{$key}_{$i}"] = $v;
91 91
                     }
92 92
                 } else {
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
     }
99 99
 
100 100
     public function setBoundData($key, $value) {
101
-        if(isset($this->boundData[$key])){
101
+        if (isset($this->boundData[$key])) {
102 102
             $isArray = is_array($value);
103 103
             $boundArray = in_array($key, $this->boundArrays);
104
-            if($isArray && !$boundArray) {
104
+            if ($isArray && !$boundArray) {
105 105
                 throw new NibiiException("{$key} cannot be bound to an array");
106 106
             } else if (!$isArray && $boundArray) {
107 107
                 throw new NibiiException("{$key} must be bound to an array");
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
     }
115 115
 
116 116
     public function getSorts() {
117
-        return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null;
117
+        return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null;
118 118
     }
119 119
 
120 120
     public function addFilter($field, $values = null) {
Please login to merge, or discard this patch.
src/relationships/HasManyRelationship.php 2 patches
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@
 block discarded – undo
26 26
 
27 27
 namespace ntentan\nibii\relationships;
28 28
 
29
-use ntentan\utils\Text;
30 29
 use ntentan\nibii\ORMContext;
30
+use ntentan\utils\Text;
31 31
 
32 32
 class HasManyRelationship extends \ntentan\nibii\Relationship {
33 33
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 
54 54
     public function runSetup() {
55 55
         if ($this->options['foreign_key'] == null) {
56
-            $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id';
56
+            $this->options['foreign_key'] = Text::singularize($this->setupTable).'_id';
57 57
         }
58 58
         if ($this->options['local_key'] == null) {
59 59
             $this->options['local_key'] = $this->setupPrimaryKey[0];
Please login to merge, or discard this patch.
src/relationships/ManyHaveManyRelationship.php 2 patches
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
 
27 27
 namespace ntentan\nibii\relationships;
28 28
 
29
-use ntentan\utils\Text;
30
-use ntentan\nibii\ORMContext;
31 29
 use ntentan\nibii\NibiiException;
30
+use ntentan\nibii\ORMContext;
31
+use ntentan\utils\Text;
32 32
 
33 33
 class ManyHaveManyRelationship extends \ntentan\nibii\Relationship {
34 34
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $filter = $junctionModel->fields($this->options['junction_foreign_key'])
47 47
             ->filterBy($this->options['junction_local_key'], $data[$this->options['local_key']])
48 48
             ->fetch();
49
-        if($filter->count() == 0) {
49
+        if ($filter->count() == 0) {
50 50
             return null;
51 51
         }
52 52
         $foreignKeys = [];
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
         // @todo throw an exception when the data doesn't have the local key
58 58
         $query = $this->getQuery();
59
-        if($this->queryPrepared){
59
+        if ($this->queryPrepared) {
60 60
             $query->setBoundData($this->options['foreign_key'], $foreignKeys);
61 61
         } else {
62 62
             $query = $this->getQuery()
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 
91 91
         if (!isset($this->options['junction_local_key'])) {
92 92
             $this->options['junction_local_key'] = 
93
-                Text::singularize($this->setupTable) . '_id';
93
+                Text::singularize($this->setupTable).'_id';
94 94
         }
95 95
 
96 96
         if (!isset($this->options['junction_foreign_key'])) {
97 97
             $this->options['junction_foreign_key'] = 
98
-                Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id';
98
+                Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id';
99 99
         }
100 100
     }  
101 101
     
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
     
111 111
     public function postSave(&$wrapper) {
112 112
         $jointModelRecords = [];
113
-        foreach($this->tempdata as $relatedRecord) {
113
+        foreach ($this->tempdata as $relatedRecord) {
114 114
             $data = $relatedRecord->toArray();
115
-            if(!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) {
116
-                if(!$relatedRecord->save()) {
115
+            if (!isset($data[$this->options['foreign_key']]) || (isset($data[$this->options['foreign_key']]) && count($data) > 1)) {
116
+                if (!$relatedRecord->save()) {
117 117
                     throw new NibiiException("Failed to save related model {$this->options['model']}");
118 118
                 }
119 119
             }
Please login to merge, or discard this patch.
src/DataOperations.php 1 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/Resolver.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 use ntentan\nibii\interfaces\ModelClassResolverInterface;
6 6
 use ntentan\nibii\interfaces\ModelJoinerInterface;
7 7
 use ntentan\nibii\interfaces\TableNameResolverInterface;
8
-use ntentan\config\Config;
9 8
 use ntentan\utils\Text;
10 9
 
11 10
 /**
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) {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
     public static function getDriverAdapterClassName($driver = false) {
53 53
         if ($driver) {
54
-            return __NAMESPACE__ . '\adapters\\' . Text::ucamelize($driver) . 'Adapter';
54
+            return __NAMESPACE__.'\adapters\\'.Text::ucamelize($driver).'Adapter';
55 55
         }
56 56
         throw new NibiiException("Please specify a driver");
57 57
     }
Please login to merge, or discard this patch.