Completed
Push — master ( 6bc7cf...be821e )
by James Ekow Abaka
05:06
created
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/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.
src/ModelDescription.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -90,6 +90,9 @@
 block discarded – undo
90 90
         return $relationshipDetails;
91 91
     }
92 92
 
93
+    /**
94
+     * @param string $type
95
+     */
93 96
     private function createRelationships($type, $relationships) {
94 97
         foreach ($relationships as $relationship) {
95 98
             $relationship = $this->getRelationshipDetails($relationship);
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
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
     /**
124 124
      * @method
125
-     * @param type $name
125
+     * @param string $name
126 126
      * @param type $arguments
127 127
      * @return type
128 128
      */
@@ -148,6 +148,10 @@  discard block
 block discarded – undo
148 148
         return $this->retrieveItem($name);
149 149
     }
150 150
 
151
+    /**
152
+     * @param Relationship[] $relationships
153
+     * @param integer $depth
154
+     */
151 155
     private function expandArrayValue($array, $relationships, $depth, $index = null) {
152 156
         foreach ($relationships as $name => $relationship) {
153 157
             $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,6 @@
 block discarded – undo
28 28
 
29 29
 use ntentan\kaikai\Cache;
30 30
 use ntentan\utils\Text;
31
-use ntentan\atiaa\Db;
32 31
 
33 32
 /**
34 33
  * 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
             $this->quotedTable = $driver->quoteIdentifier($table);
62 62
             $this->table = $this->unquotedTable = $table;
63 63
         } else {
64
-            $this->quotedTable = ( isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : "") . $driver->quoteIdentifier($table["table"]);
65
-            $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "") . $table['table'];
64
+            $this->quotedTable = (isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : "").$driver->quoteIdentifier($table["table"]);
65
+            $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "").$table['table'];
66 66
             $this->table = $table['table'];
67 67
             $this->schema = $table['schema'];
68 68
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function getDescription() {
82 82
         return Cache::read(
83
-            (new \ReflectionClass($this))->getName() . '::desc', function() {
83
+            (new \ReflectionClass($this))->getName().'::desc', function() {
84 84
                 return new ModelDescription($this);
85 85
             }
86 86
         );
Please login to merge, or discard this patch.
src/QueryEngine.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
         }
35 35
 
36 36
         return $this->filter(
37
-            "INSERT INTO " . $table .
38
-            " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")"
37
+            "INSERT INTO ".$table.
38
+            " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")"
39 39
         );
40 40
     }
41 41
 
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
             }
78 78
         }
79 79
 
80
-        return $this->filter("UPDATE " .
81
-            $model->getDBStoreInformation()['quoted_table'] .
82
-            " SET " . implode(', ', $valueFields) .
83
-            " WHERE " . implode(' AND ', $conditions)
80
+        return $this->filter("UPDATE ".
81
+            $model->getDBStoreInformation()['quoted_table'].
82
+            " SET ".implode(', ', $valueFields).
83
+            " WHERE ".implode(' AND ', $conditions)
84 84
         );
85 85
     }
86 86
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
         $this->db = $driver;
11 11
     }
12 12
  
13
+    /**
14
+     * @param string $query
15
+     */
13 16
     private function filter($query) {
14 17
         return $query;
15 18
     }
Please login to merge, or discard this patch.
src/QueryParameters.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     }
71 71
 
72 72
     public function getSorts() {
73
-        return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null;
73
+        return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null;
74 74
     }
75 75
 
76 76
     public function addFilter($field, $values = []) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
             $this->whereClause .= "{$field} IN (";
91 91
             $comma = '';
92 92
             for ($i = 0; $i < $numValues; $i++) {
93
-                $key = "filter_" . ($startIndex + $i);
93
+                $key = "filter_".($startIndex + $i);
94 94
                 $this->whereClause .= "$comma:$key";
95 95
                 $this->boundData[$key] = $values[$i];
96 96
                 $comma = ' ,';
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@  discard block
 block discarded – undo
23 23
 
24 24
     /**
25 25
      *
26
-     * @param \ $model
27 26
      */
28 27
     public function __construct(DriverAdapter $db, $table) {
29 28
         $this->db = $db;
@@ -106,6 +105,9 @@  discard block
 block discarded – undo
106 105
         $this->boundData += $values;
107 106
     }
108 107
 
108
+    /**
109
+     * @param boolean $firstOnly
110
+     */
109 111
     public function setFirstOnly($firstOnly) {
110 112
         $this->firstOnly = $firstOnly;
111 113
         return $this;
@@ -123,6 +125,9 @@  discard block
 block discarded – undo
123 125
         $this->offset = $offset;
124 126
     }
125 127
 
128
+    /**
129
+     * @param string $field
130
+     */
126 131
     public function addSort($field, $direction = 'ASC') {
127 132
         $this->sorts[] = "$field $direction";
128 133
     }
Please login to merge, or discard this patch.
src/relationships/ManyHaveManyRelationship.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,11 +70,11 @@
 block discarded – undo
70 70
         }
71 71
 
72 72
         if (!isset($this->options['junction_local_key'])) {
73
-            $this->options['junction_local_key'] = Text::singularize($this->setupTable) . '_id';
73
+            $this->options['junction_local_key'] = Text::singularize($this->setupTable).'_id';
74 74
         }
75 75
 
76 76
         if (!isset($this->options['junction_foreign_key'])) {
77
-            $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getDBStoreInformation()['table']) . '_id';
77
+            $this->options['junction_foreign_key'] = Text::singularize($foreignModel->getDBStoreInformation()['table']).'_id';
78 78
         }
79 79
     }
80 80
 
Please login to merge, or discard this patch.
Unused Use Statements   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
 namespace ntentan\nibii\relationships;
28 28
 
29 29
 use ntentan\nibii\Nibii;
30
-use ntentan\utils\Text;
31 30
 use ntentan\panie\InjectionContainer;
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.
src/relationships/BelongsToRelationship.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@
 block discarded – undo
47 47
     {
48 48
         $model = InjectionContainer::resolve(Nibii::getClassName($this->options['model'], self::BELONGS_TO));
49 49
         $table = $model->getDBStoreInformation()['table'];
50
-        if($this->options['foreign_key'] == null) {
50
+        if ($this->options['foreign_key'] == null) {
51 51
             $this->options['foreign_key'] = $model->getDescription()->getPrimaryKey()[0];
52 52
         }
53
-        if($this->options['local_key'] == null) {
54
-            $this->options['local_key'] = Text::singularize($table) . '_id';
53
+        if ($this->options['local_key'] == null) {
54
+            $this->options['local_key'] = Text::singularize($table).'_id';
55 55
         }
56 56
     }
57 57
 }
Please login to merge, or discard this patch.
Unused Use Statements   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
 
27 27
 namespace ntentan\nibii\relationships;
28 28
 
29
-use ntentan\nibii\QueryParameters;
30
-use ntentan\utils\Text;
31 29
 use ntentan\nibii\Nibii;
30
+use ntentan\nibii\QueryParameters;
32 31
 use ntentan\panie\InjectionContainer;
32
+use ntentan\utils\Text;
33 33
 
34 34
 class BelongsToRelationship extends \ntentan\nibii\Relationship
35 35
 {
Please login to merge, or discard this patch.
src/Context.php 4 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -52,11 +52,17 @@
 block discarded – undo
52 52
             ->getJunctionClassName($classA, $classB);
53 53
     }
54 54
 
55
+    /**
56
+     * @param RecordWrapper $instance
57
+     */
55 58
     public function getModelTable($instance) {
56 59
         return$this->container->singleton(interfaces\TableNameResolverInterface::class)
57 60
             ->getTableName($instance);
58 61
     }
59 62
 
63
+    /**
64
+     * @param string $model
65
+     */
60 66
     public function getClassName($model, $context = null) {
61 67
         return$this->container->singleton(interfaces\ModelClassResolverInterface::class)
62 68
             ->getModelClassName($model, $context);
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
         $this->container = $container;
19 19
         $this->dbContext = $container->resolve(\ntentan\atiaa\DbContext::class);
20 20
         $this->container->bind(interfaces\ModelJoinerInterface::class)
21
-             ->to(Resolver::class);
21
+                ->to(Resolver::class);
22 22
         $this->container->bind(interfaces\TableNameResolverInterface::class)
23
-             ->to(Resolver::class);
23
+                ->to(Resolver::class);
24 24
         $this->container->bind(interfaces\ModelClassResolverInterface::class)
25
-             ->to(Resolver::class);
25
+                ->to(Resolver::class);
26 26
         self::$instance = $this;
27 27
     }
28 28
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
     }
68 68
     
69 69
     public static function getInstance() {
70
-        if(self::$instance === null) throw new NibiiException("A context has not yet been initialized");
70
+        if (self::$instance === null) throw new NibiiException("A context has not yet been initialized");
71 71
         return self::$instance;
72 72
     }
73 73
     
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,9 @@
 block discarded – undo
67 67
     }
68 68
     
69 69
     public static function getInstance() {
70
-        if(self::$instance === null) throw new NibiiException("A context has not yet been initialized");
70
+        if(self::$instance === null) {
71
+            throw new NibiiException("A context has not yet been initialized");
72
+        }
71 73
         return self::$instance;
72 74
     }
73 75
     
Please login to merge, or discard this patch.