@@ -34,29 +34,29 @@ |
||
34 | 34 | |
35 | 35 | $query .= $Column->type; |
36 | 36 | |
37 | - if(isset($Column->length)) |
|
37 | + if (isset($Column->length)) |
|
38 | 38 | $query .= "(".$Column->length; |
39 | 39 | |
40 | - if(isset($Column->scale) && isset($Column->length)) { |
|
40 | + if (isset($Column->scale) && isset($Column->length)) { |
|
41 | 41 | $query .= ", ".$Column->scale.")"; |
42 | 42 | } else { |
43 | - if(isset($Column->length)) |
|
43 | + if (isset($Column->length)) |
|
44 | 44 | $query .= ")"; |
45 | 45 | } |
46 | 46 | |
47 | - if($Column->isUnsigned) |
|
47 | + if ($Column->isUnsigned) |
|
48 | 48 | $query .= " UNSIGNED"; |
49 | 49 | |
50 | - if($Column->isNull) |
|
50 | + if ($Column->isNull) |
|
51 | 51 | $query .= " NOT NULL"; |
52 | 52 | |
53 | - if($Column->isAutoIncrement) |
|
53 | + if ($Column->isAutoIncrement) |
|
54 | 54 | $query .= " AUTO_INCREMENT"; |
55 | 55 | |
56 | - if($Column->isPrimaryKey) |
|
56 | + if ($Column->isPrimaryKey) |
|
57 | 57 | $query .= " PRIMARY KEY"; |
58 | 58 | |
59 | - if(count($table->getColumns())-1 != $key) |
|
59 | + if (count($table->getColumns()) - 1 != $key) |
|
60 | 60 | $query .= ", "; |
61 | 61 | } |
62 | 62 | $query .= ");"; |
@@ -34,30 +34,37 @@ |
||
34 | 34 | |
35 | 35 | $query .= $Column->type; |
36 | 36 | |
37 | - if(isset($Column->length)) |
|
38 | - $query .= "(".$Column->length; |
|
37 | + if(isset($Column->length)) { |
|
38 | + $query .= "(".$Column->length; |
|
39 | + } |
|
39 | 40 | |
40 | 41 | if(isset($Column->scale) && isset($Column->length)) { |
41 | 42 | $query .= ", ".$Column->scale.")"; |
42 | 43 | } else { |
43 | - if(isset($Column->length)) |
|
44 | - $query .= ")"; |
|
44 | + if(isset($Column->length)) { |
|
45 | + $query .= ")"; |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | |
47 | - if($Column->isUnsigned) |
|
48 | - $query .= " UNSIGNED"; |
|
49 | + if($Column->isUnsigned) { |
|
50 | + $query .= " UNSIGNED"; |
|
51 | + } |
|
49 | 52 | |
50 | - if($Column->isNull) |
|
51 | - $query .= " NOT NULL"; |
|
53 | + if($Column->isNull) { |
|
54 | + $query .= " NOT NULL"; |
|
55 | + } |
|
52 | 56 | |
53 | - if($Column->isAutoIncrement) |
|
54 | - $query .= " AUTO_INCREMENT"; |
|
57 | + if($Column->isAutoIncrement) { |
|
58 | + $query .= " AUTO_INCREMENT"; |
|
59 | + } |
|
55 | 60 | |
56 | - if($Column->isPrimaryKey) |
|
57 | - $query .= " PRIMARY KEY"; |
|
61 | + if($Column->isPrimaryKey) { |
|
62 | + $query .= " PRIMARY KEY"; |
|
63 | + } |
|
58 | 64 | |
59 | - if(count($table->getColumns())-1 != $key) |
|
60 | - $query .= ", "; |
|
65 | + if(count($table->getColumns())-1 != $key) { |
|
66 | + $query .= ", "; |
|
67 | + } |
|
61 | 68 | } |
62 | 69 | $query .= ");"; |
63 | 70 |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | * @param array|mixed $columns |
114 | 114 | * @return $this |
115 | 115 | */ |
116 | - public function select($columns = ['*']) |
|
116 | + public function select($columns = [ '*' ]) |
|
117 | 117 | { |
118 | 118 | $this->columns = is_array($columns) ? $columns : func_get_args(); |
119 | 119 | |
120 | 120 | return $this; |
121 | 121 | } |
122 | 122 | |
123 | - public function selectRaw(string $query, array $bindings = []) |
|
123 | + public function selectRaw(string $query, array $bindings = [ ]) |
|
124 | 124 | { |
125 | 125 | return $this->connection->select($query, $bindings); |
126 | 126 | } |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | return true; |
132 | 132 | } |
133 | 133 | |
134 | - if (! is_array(reset($values))) { |
|
135 | - $values = [$values]; |
|
134 | + if (!is_array(reset($values))) { |
|
135 | + $values = [ $values ]; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | // Here, we will sort the insert keys for every record so that each insert is |
@@ -141,18 +141,18 @@ discard block |
||
141 | 141 | else { |
142 | 142 | foreach ($values as $key => $value) { |
143 | 143 | ksort($value); |
144 | - $values[$key] = $value; |
|
144 | + $values[ $key ] = $value; |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
148 | 148 | // We'll treat every insert like a batch insert so we can easily insert each |
149 | 149 | // of the records into the database consistently. This will make it much |
150 | 150 | // easier on the grammars to just handle one type of record insertion. |
151 | - $bindings = []; |
|
151 | + $bindings = [ ]; |
|
152 | 152 | |
153 | 153 | foreach ($values as $record) { |
154 | 154 | foreach ($record as $value) { |
155 | - $bindings[] = $value; |
|
155 | + $bindings[ ] = $value; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
@@ -166,17 +166,17 @@ discard block |
||
166 | 166 | return $this->connection->insert($sql); |
167 | 167 | } |
168 | 168 | |
169 | - public function insertRaw(string $query, array $bindings = []) |
|
169 | + public function insertRaw(string $query, array $bindings = [ ]) |
|
170 | 170 | { |
171 | 171 | return $this->connection->insert($query, $bindings); |
172 | 172 | } |
173 | 173 | |
174 | - public function updateRaw(string $query, array $bindings = []) |
|
174 | + public function updateRaw(string $query, array $bindings = [ ]) |
|
175 | 175 | { |
176 | 176 | return $this->connection->update($query, $bindings); |
177 | 177 | } |
178 | 178 | |
179 | - public function deleteRaw(string $query, array $bindings = []) |
|
179 | + public function deleteRaw(string $query, array $bindings = [ ]) |
|
180 | 180 | { |
181 | 181 | return $this->connection->delete($query, $bindings); |
182 | 182 | } |
@@ -206,12 +206,12 @@ discard block |
||
206 | 206 | public function where($column, $operator = "=", $value = null, $bool = 'and') |
207 | 207 | { |
208 | 208 | // check if operator is valid |
209 | - if(!$this->isOperatorValid($operator)) { |
|
209 | + if (!$this->isOperatorValid($operator)) { |
|
210 | 210 | handle(new \Exception("Where operator not valid: '".$operator."'")); |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Add prepared data to where array |
214 | - $this->wheres[] = [ |
|
214 | + $this->wheres[ ] = [ |
|
215 | 215 | $column, |
216 | 216 | $operator, |
217 | 217 | $value, |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function orderBy($column, $direction = 'asc') |
232 | 232 | { |
233 | - if(!($direction == 'asc' or $direction == 'desc')) |
|
233 | + if (!($direction == 'asc' or $direction == 'desc')) |
|
234 | 234 | handle(new \Exception("Order by direction invalid: '".$direction."'")); |
235 | 235 | |
236 | 236 | $this->orders = [ |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | private function isOperatorValid($operatorToCheck) |
264 | 264 | { |
265 | 265 | foreach ($this->operators as $operator) { |
266 | - if($operatorToCheck === $operator) |
|
266 | + if ($operatorToCheck === $operator) |
|
267 | 267 | return true; |
268 | 268 | } |
269 | 269 | |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | */ |
289 | 289 | protected function cleanBindings(array $bindings) |
290 | 290 | { |
291 | - return array_values(array_filter($bindings, function ($binding) { |
|
292 | - return ! $binding instanceof Expression; |
|
291 | + return array_values(array_filter($bindings, function($binding) { |
|
292 | + return !$binding instanceof Expression; |
|
293 | 293 | })); |
294 | 294 | } |
295 | 295 | |
@@ -303,13 +303,13 @@ discard block |
||
303 | 303 | protected function prepareRawQuery(string $query, array $bindings): string |
304 | 304 | { |
305 | 305 | // search for values in query |
306 | - preg_match_all("/:([^ ]*)/", $query,$values); |
|
306 | + preg_match_all("/:([^ ]*)/", $query, $values); |
|
307 | 307 | |
308 | 308 | // replace values with bindings |
309 | - foreach ($values[1] as $value) { |
|
309 | + foreach ($values[ 1 ] as $value) { |
|
310 | 310 | // check if fitting binding exists |
311 | - if(array_key_exists($value, $bindings)) { |
|
312 | - $query = str_replace(":".$value, $bindings[$value], $query); |
|
311 | + if (array_key_exists($value, $bindings)) { |
|
312 | + $query = str_replace(":".$value, $bindings[ $value ], $query); |
|
313 | 313 | } else { |
314 | 314 | handle(new \Exception("Could not find fitting value '$value' in bindings for query: '$query'")); |
315 | 315 | } |
@@ -230,8 +230,9 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function orderBy($column, $direction = 'asc') |
232 | 232 | { |
233 | - if(!($direction == 'asc' or $direction == 'desc')) |
|
234 | - handle(new \Exception("Order by direction invalid: '".$direction."'")); |
|
233 | + if(!($direction == 'asc' or $direction == 'desc')) { |
|
234 | + handle(new \Exception("Order by direction invalid: '".$direction."'")); |
|
235 | + } |
|
235 | 236 | |
236 | 237 | $this->orders = [ |
237 | 238 | $column, |
@@ -263,8 +264,9 @@ discard block |
||
263 | 264 | private function isOperatorValid($operatorToCheck) |
264 | 265 | { |
265 | 266 | foreach ($this->operators as $operator) { |
266 | - if($operatorToCheck === $operator) |
|
267 | - return true; |
|
267 | + if($operatorToCheck === $operator) { |
|
268 | + return true; |
|
269 | + } |
|
268 | 270 | } |
269 | 271 | |
270 | 272 | return false; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $original = $query->columns; |
56 | 56 | |
57 | 57 | if (is_null($query->columns)) { |
58 | - $query->columns = ['*']; |
|
58 | + $query->columns = [ '*' ]; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | // To compile the query, we'll spin through each component of the query and |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | { |
82 | 82 | $table = $this->wrapTable($query->from); |
83 | 83 | |
84 | - if (! is_array(reset($values))) { |
|
85 | - $values = [$values]; |
|
84 | + if (!is_array(reset($values))) { |
|
85 | + $values = [ $values ]; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $columns = $this->columnize(array_keys(reset($values))); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // We need to build a list of parameter place-holders of values that are bound |
91 | 91 | // to the query. Each insert should have the exact same amount of parameter |
92 | 92 | // bindings so we will loop through the record and parameterize them all. |
93 | - $parameters = arr($values)->map(function ($record) { |
|
93 | + $parameters = arr($values)->map(function($record) { |
|
94 | 94 | return '('.$this->parameterize($record).')'; |
95 | 95 | })->implode(', '); |
96 | 96 | |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function compileComponents(Builder $query) |
107 | 107 | { |
108 | - $sql = []; |
|
108 | + $sql = [ ]; |
|
109 | 109 | |
110 | 110 | foreach ($this->selectComponents as $component) { |
111 | 111 | // To compile the query, we'll spin through each component of the query and |
112 | 112 | // see if that component exists. If it does we'll just call the compiler |
113 | 113 | // function for the component which is responsible for making the SQL. |
114 | 114 | if (!is_null($query->$component)) { |
115 | - $method = 'compile' . ucfirst($component); |
|
115 | + $method = 'compile'.ucfirst($component); |
|
116 | 116 | |
117 | - $sql[$component] = $this->$method($query, $query->$component); |
|
117 | + $sql[ $component ] = $this->$method($query, $query->$component); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | $select = $query->distinct ? 'select distinct ' : 'select '; |
141 | 141 | |
142 | - return $select . $this->columnize($columns); |
|
142 | + return $select.$this->columnize($columns); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function compileFrom(Builder $query, $table) |
153 | 153 | { |
154 | - return 'from ' . $this->wrapTable($table); |
|
154 | + return 'from '.$this->wrapTable($table); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -182,29 +182,29 @@ discard block |
||
182 | 182 | { |
183 | 183 | $sql = "ORDER BY "; |
184 | 184 | |
185 | - if(is_array($orders[0])) { |
|
185 | + if (is_array($orders[ 0 ])) { |
|
186 | 186 | $i = 1; |
187 | - $count = count($orders[0]); |
|
188 | - foreach ($orders[0] as $column) { |
|
187 | + $count = count($orders[ 0 ]); |
|
188 | + foreach ($orders[ 0 ] as $column) { |
|
189 | 189 | $append = $count > $i ? ", " : ""; |
190 | 190 | $sql .= "`".$column."`".$append; |
191 | 191 | $i++; |
192 | 192 | } |
193 | 193 | } else { |
194 | - $sql .= $orders[0]; |
|
194 | + $sql .= $orders[ 0 ]; |
|
195 | 195 | } |
196 | 196 | |
197 | - $sql .= " ".$orders[1]; |
|
197 | + $sql .= " ".$orders[ 1 ]; |
|
198 | 198 | |
199 | 199 | return $sql; |
200 | 200 | } |
201 | 201 | |
202 | 202 | protected function concatenateWhereClauses(Builder $query, $wheres) |
203 | 203 | { |
204 | - $sql = "WHERE " . $wheres[0] . $wheres[1] . "'" . $wheres[2] . "'"; |
|
204 | + $sql = "WHERE ".$wheres[ 0 ].$wheres[ 1 ]."'".$wheres[ 2 ]."'"; |
|
205 | 205 | |
206 | - if(count($query->wheres) > 1) { |
|
207 | - $sql .= $wheres[3]; |
|
206 | + if (count($query->wheres) > 1) { |
|
207 | + $sql .= $wheres[ 3 ]; |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | return $sql; |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | */ |
219 | 219 | protected function concatenate($segments) |
220 | 220 | { |
221 | - return implode(' ', array_filter($segments, function ($value) { |
|
222 | - return (string)$value !== ''; |
|
221 | + return implode(' ', array_filter($segments, function($value) { |
|
222 | + return (string) $value !== ''; |
|
223 | 223 | })); |
224 | 224 | } |
225 | 225 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function columnize(array $columns) |
233 | 233 | { |
234 | - return implode(', ', array_map([$this, 'wrap'], $columns)); |
|
234 | + return implode(', ', array_map([ $this, 'wrap' ], $columns)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public function parameterize(array $values) |
244 | 244 | { |
245 | - return implode(', ', array_map([$this, 'parameter'], $values)); |
|
245 | + return implode(', ', array_map([ $this, 'parameter' ], $values)); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | public function quoteString($value) |
266 | 266 | { |
267 | 267 | if (is_array($value)) |
268 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
268 | + return implode(', ', array_map([ $this, __FUNCTION__ ], $value)); |
|
269 | 269 | |
270 | 270 | return "'$value'"; |
271 | 271 | } |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | public function wrapTable($table) |
281 | 281 | { |
282 | 282 | if (!$this->isExpression($table)) { |
283 | - return $this->wrap($this->tablePrefix . $table, true); |
|
283 | + return $this->wrap($this->tablePrefix.$table, true); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | return $this->getValue($table); |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | $segments = explode(' ', $value); |
307 | 307 | |
308 | 308 | if ($prefixAlias) { |
309 | - $segments[2] = $this->tablePrefix.$segments[2]; |
|
309 | + $segments[ 2 ] = $this->tablePrefix.$segments[ 2 ]; |
|
310 | 310 | } |
311 | 311 | |
312 | - return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]); |
|
312 | + return $this->wrap($segments[ 0 ]).' as '.$this->wrapValue($segments[ 2 ]); |
|
313 | 313 | } |
314 | 314 | |
315 | - $wrapped = []; |
|
315 | + $wrapped = [ ]; |
|
316 | 316 | |
317 | 317 | $segments = explode('.', $value); |
318 | 318 | |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | // segments as if it was a table and the rest as just regular values. |
322 | 322 | foreach ($segments as $key => $segment) { |
323 | 323 | if ($key == 0 && count($segments) > 1) { |
324 | - $wrapped[] = $this->wrapTable($segment); |
|
324 | + $wrapped[ ] = $this->wrapTable($segment); |
|
325 | 325 | } else { |
326 | - $wrapped[] = $this->wrapValue($segment); |
|
326 | + $wrapped[ ] = $this->wrapValue($segment); |
|
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | // as well in order to generate proper syntax. If this is a column of course |
346 | 346 | // no prefix is necessary. The condition will be true when from wrapTable. |
347 | 347 | if ($prefixAlias) { |
348 | - $segments[1] = $this->tablePrefix . $segments[1]; |
|
348 | + $segments[ 1 ] = $this->tablePrefix.$segments[ 1 ]; |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | return $this->wrap( |
352 | - $segments[0]) . ' as ' . $this->wrapValue($segments[1] |
|
352 | + $segments[ 0 ]).' as '.$this->wrapValue($segments[ 1 ] |
|
353 | 353 | ); |
354 | 354 | } |
355 | 355 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | */ |
362 | 362 | protected function wrapSegments($segments) |
363 | 363 | { |
364 | - return arr($segments)->map(function ($segment, $key) use ($segments) { |
|
364 | + return arr($segments)->map(function($segment, $key) use ($segments) { |
|
365 | 365 | return $key == 0 && count($segments) > 1 |
366 | 366 | ? $this->wrapTable($segment) |
367 | 367 | : $this->wrapValue($segment); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | protected function wrapValue($value) |
378 | 378 | { |
379 | 379 | if ($value !== '*') { |
380 | - return '`' . str_replace('"', '""', $value) . '`'; |
|
380 | + return '`'.str_replace('"', '""', $value).'`'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | return $value; |
@@ -264,8 +264,9 @@ |
||
264 | 264 | */ |
265 | 265 | public function quoteString($value) |
266 | 266 | { |
267 | - if (is_array($value)) |
|
268 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
267 | + if (is_array($value)) { |
|
268 | + return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
269 | + } |
|
269 | 270 | |
270 | 271 | return "'$value'"; |
271 | 272 | } |
@@ -23,23 +23,23 @@ |
||
23 | 23 | * @param array $bindings |
24 | 24 | * @return array |
25 | 25 | */ |
26 | - static function select(string $query, array $bindings = []) |
|
26 | + static function select(string $query, array $bindings = [ ]) |
|
27 | 27 | { |
28 | 28 | return (new Manager)->selectRaw($query, $bindings); |
29 | 29 | } |
30 | 30 | |
31 | - static function insert(string $query, array $bindings = []) |
|
31 | + static function insert(string $query, array $bindings = [ ]) |
|
32 | 32 | { |
33 | 33 | return (new Manager)->insertRaw($query, $bindings); |
34 | 34 | } |
35 | 35 | |
36 | - static function update(string $query, array $bindings = []) |
|
36 | + static function update(string $query, array $bindings = [ ]) |
|
37 | 37 | { |
38 | 38 | return (new Manager)->updateRaw($query, $bindings); |
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | - static function delete(string $query, array $bindings = []) |
|
42 | + static function delete(string $query, array $bindings = [ ]) |
|
43 | 43 | { |
44 | 44 | return (new Manager)->deleteRaw($query, $bindings); |
45 | 45 | } |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | |
11 | 11 | use app\framework\Component\ClassLoader\Loader; |
12 | 12 | |
13 | -require_once __DIR__ . "/Loader/Psr0.php"; |
|
14 | -require_once __DIR__ . "/Loader/Psr4.php"; |
|
13 | +require_once __DIR__."/Loader/Psr0.php"; |
|
14 | +require_once __DIR__."/Loader/Psr4.php"; |
|
15 | 15 | |
16 | 16 | class ClassLoader |
17 | 17 | { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function getClass($class) |
24 | 24 | { |
25 | - if($file = $this->loadClass($class)){ |
|
25 | + if ($file = $this->loadClass($class)) { |
|
26 | 26 | require($file); |
27 | 27 | |
28 | 28 | return true; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | namespace app\framework\Component\ClassLoader\Loader; |
10 | 10 | |
11 | -require __DIR__ . "/AbstractLoader.php"; |
|
11 | +require __DIR__."/AbstractLoader.php"; |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Psr0 autoloader |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | if ($lastNsPos = strrpos($className, '\\')) { |
26 | 26 | $namespace = substr($className, 0, $lastNsPos); |
27 | 27 | $className = substr($className, $lastNsPos + 1); |
28 | - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
|
28 | + $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR; |
|
29 | 29 | } |
30 | - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
30 | + $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
31 | 31 | |
32 | - if(file_exists(ROOT_PATH.DIRECTORY_SEPARATOR.$fileName)) |
|
32 | + if (file_exists(ROOT_PATH.DIRECTORY_SEPARATOR.$fileName)) |
|
33 | 33 | return ROOT_PATH.DIRECTORY_SEPARATOR.$fileName; |
34 | 34 | |
35 | 35 | return false; |
@@ -29,8 +29,9 @@ |
||
29 | 29 | } |
30 | 30 | $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
31 | 31 | |
32 | - if(file_exists(ROOT_PATH.DIRECTORY_SEPARATOR.$fileName)) |
|
33 | - return ROOT_PATH.DIRECTORY_SEPARATOR.$fileName; |
|
32 | + if(file_exists(ROOT_PATH.DIRECTORY_SEPARATOR.$fileName)) { |
|
33 | + return ROOT_PATH.DIRECTORY_SEPARATOR.$fileName; |
|
34 | + } |
|
34 | 35 | |
35 | 36 | return false; |
36 | 37 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function __construct($key, $cipher = Ciphers::AES_128_CBC) |
31 | 31 | { |
32 | - $key = (string)$key; |
|
32 | + $key = (string) $key; |
|
33 | 33 | |
34 | 34 | if (static::supported($key, $cipher)) { |
35 | 35 | $this->key = $key; |
@@ -121,13 +121,13 @@ discard block |
||
121 | 121 | { |
122 | 122 | $payload = $this->getJsonPayload($payload); |
123 | 123 | |
124 | - $iv = base64_decode($payload['iv']); |
|
124 | + $iv = base64_decode($payload[ 'iv' ]); |
|
125 | 125 | |
126 | 126 | // Here we will decrypt the value. If we are able to successfully decrypt it |
127 | 127 | // we will then unserialize it and return it out to the caller. If we are |
128 | 128 | // unable to decrypt this value we will throw out an exception message. |
129 | 129 | $decrypted = \openssl_decrypt( |
130 | - $payload['value'], $this->cipher, $this->key, 0, $iv |
|
130 | + $payload[ 'value' ], $this->cipher, $this->key, 0, $iv |
|
131 | 131 | ); |
132 | 132 | |
133 | 133 | if ($decrypted === false) { |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | // If the payload is not valid JSON or does not have the proper keys set we will |
170 | 170 | // assume it is invalid and bail out of the routine since we will not be able |
171 | 171 | // to decrypt the given value. We'll also check the MAC for this encryption. |
172 | - if (! $this->validPayload($payload)) { |
|
172 | + if (!$this->validPayload($payload)) { |
|
173 | 173 | throw new DecryptException('The payload is invalid.'); |
174 | 174 | } |
175 | 175 | |
176 | - if (! $this->validMac($payload)) { |
|
176 | + if (!$this->validMac($payload)) { |
|
177 | 177 | throw new DecryptException('The MAC is invalid.'); |
178 | 178 | } |
179 | 179 | |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | */ |
189 | 189 | protected function validPayload($payload) |
190 | 190 | { |
191 | - return is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac']) && |
|
192 | - strlen(base64_decode($payload['iv'], true)) === openssl_cipher_iv_length($this->cipher); |
|
191 | + return is_array($payload) && isset($payload[ 'iv' ], $payload[ 'value' ], $payload[ 'mac' ]) && |
|
192 | + strlen(base64_decode($payload[ 'iv' ], true)) === openssl_cipher_iv_length($this->cipher); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $calculated = $this->calculateMac($payload, $bytes = random_bytes(16)); |
205 | 205 | |
206 | 206 | return hash_equals( |
207 | - hash_hmac('sha256', $payload['mac'], $bytes, true), $calculated |
|
207 | + hash_hmac('sha256', $payload[ 'mac' ], $bytes, true), $calculated |
|
208 | 208 | ); |
209 | 209 | } |
210 | 210 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | protected function calculateMac($payload, $bytes) |
219 | 219 | { |
220 | 220 | return hash_hmac( |
221 | - 'sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true |
|
221 | + 'sha256', $this->hash($payload[ 'iv' ], $payload[ 'value' ]), $bytes, true |
|
222 | 222 | ); |
223 | 223 | } |
224 | 224 |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | $eventListener = new EventListener(); |
60 | 60 | } |
61 | 61 | |
62 | - $eventListeners = $this->events->key($eventName, [], true); |
|
63 | - $eventListeners[] = $eventListener; |
|
62 | + $eventListeners = $this->events->key($eventName, [ ], true); |
|
63 | + $eventListeners[ ] = $eventListener; |
|
64 | 64 | $this->events->key($eventName, $eventListeners); |
65 | 65 | |
66 | 66 | return $eventListener; |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $eventListeners = $this->events->key($eventName); |
105 | 105 | |
106 | 106 | // to prevent error on empty listeners |
107 | - $eventListeners = $eventListeners ?: []; |
|
107 | + $eventListeners = $eventListeners ?: [ ]; |
|
108 | 108 | |
109 | 109 | if (!$this->isInstanceOf($data, '\app\framework\EventManager\Event')) { |
110 | 110 | $data = new Event($data); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getEventListeners($eventName) |
152 | 152 | { |
153 | - return $this->events->key($eventName, [], true); |
|
153 | + return $this->events->key($eventName, [ ], true); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | // get event prefix |
178 | 178 | $eventPrefix = $this->str($eventName)->subString(0, -1)->val(); |
179 | 179 | // Find events starting with the prefix |
180 | - $events = []; |
|
180 | + $events = [ ]; |
|
181 | 181 | foreach ($this->events as $eventName => $eventListeners) { |
182 | 182 | if ($this->str($eventName)->startsWith($eventPrefix)) { |
183 | - $events[$eventName] = $eventListeners; |
|
183 | + $events[ $eventName ] = $eventListeners; |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | if (!$this->isArray($eventData) && !$this->isArrayObject($eventData)) { |
31 | 31 | handle(new EventManagerException( |
32 | 32 | EventManagerException::MSG_INVALID_ARG, |
33 | - ['$eventData', 'array|ArrayObject']) |
|
33 | + [ '$eventData', 'array|ArrayObject' ]) |
|
34 | 34 | ); |
35 | 35 | } |
36 | 36 | $this->eventData = $this->arr($eventData); |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | if ($this->isNull($name)) { |
69 | - $this->eventData[] = $value; |
|
69 | + $this->eventData[ ] = $value; |
|
70 | 70 | } else { |
71 | - $this->eventData[$name] = $value; |
|
71 | + $this->eventData[ $name ] = $value; |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | */ |
230 | 230 | public function toArray() |
231 | 231 | { |
232 | - $data = []; |
|
232 | + $data = [ ]; |
|
233 | 233 | foreach ($this->eventData as $k => $v) { |
234 | - $data[$k] = $v; |
|
234 | + $data[ $k ] = $v; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $data; |