@@ -11,7 +11,7 @@ |
||
11 | 11 | use app\framework\Component\Routing\Router; |
12 | 12 | |
13 | 13 | Router::get("/", function() { |
14 | - view("welcome", ["version" => version()]); |
|
14 | + view("welcome", [ "version" => version() ]); |
|
15 | 15 | }); |
16 | 16 | |
17 | 17 | Router::get("/home", function() { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | class SessionGuard |
23 | 23 | { |
24 | - use SingletonTrait,EventManagerTrait; |
|
24 | + use SingletonTrait, EventManagerTrait; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * The currently authenticated user. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function check() |
80 | 80 | { |
81 | - return ! is_null($this->user()); |
|
81 | + return !is_null($this->user()); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function guest() |
91 | 91 | { |
92 | - return ! $this->check(); |
|
92 | + return !$this->check(); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | // If we've already retrieved the user for the current request we can just |
133 | 133 | // return it back immediately. We do not want to fetch the user data on |
134 | 134 | // every call to this method because that would be tremendously slow. |
135 | - if (! is_null($this->user)) { |
|
135 | + if (!is_null($this->user)) { |
|
136 | 136 | return $this->user; |
137 | 137 | } |
138 | 138 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | // request, and if one exists, attempt to retrieve the user using that. |
144 | 144 | $user = null; |
145 | 145 | |
146 | - if (! is_null($id)) { |
|
146 | + if (!is_null($id)) { |
|
147 | 147 | $user = $this->provider->retrieveById($id); |
148 | 148 | } |
149 | 149 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | // the application. Once we have a user we can return it to the caller. |
153 | 153 | $recaller = $this->getRecaller(); |
154 | 154 | |
155 | - if (is_null($user) && ! is_null($recaller)) { |
|
155 | + if (is_null($user) && !is_null($recaller)) { |
|
156 | 156 | $user = $this->getUserByRecaller($recaller); |
157 | 157 | |
158 | 158 | if ($user) { |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return bool |
175 | 175 | * @throws StringObjectException |
176 | 176 | */ |
177 | - public function attempt(array $credentials = [], bool $remember = false, $login = true): bool |
|
177 | + public function attempt(array $credentials = [ ], bool $remember = false, $login = true): bool |
|
178 | 178 | { |
179 | 179 | $this->fireAttemptingEvent($credentials, $remember, $login); |
180 | 180 | |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function createRememberTokenIfDoesntExist() |
198 | 198 | { |
199 | - if (! isset($this->user->remember_token)) { |
|
199 | + if (!isset($this->user->remember_token)) { |
|
200 | 200 | $this->refreshRememberToken(); |
201 | 201 | } |
202 | 202 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | { |
211 | 211 | $this->session->remove($this->getName()); |
212 | 212 | |
213 | - if (! is_null($this->getRecaller())) { |
|
213 | + if (!is_null($this->getRecaller())) { |
|
214 | 214 | $recaller = $this->getRecallerName(); |
215 | 215 | |
216 | 216 | setcookie($recaller, null, -1, '/'); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | // listening for anytime a user signs out of this application manually. |
263 | 263 | $this->clearUserDataFromStorage(); |
264 | 264 | |
265 | - if (! is_null($this->user)) { |
|
265 | + if (!is_null($this->user)) { |
|
266 | 266 | $this->refreshRememberToken(); |
267 | 267 | } |
268 | 268 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @param bool $login |
283 | 283 | * @throws StringObjectException |
284 | 284 | */ |
285 | - protected function fireAttemptingEvent(array $credentials = [], bool $remember = false, $login = true) |
|
285 | + protected function fireAttemptingEvent(array $credentials = [ ], bool $remember = false, $login = true) |
|
286 | 286 | { |
287 | 287 | $this->eventManager()->fire("auth.attempting", [ |
288 | 288 | 'credentials' => $credentials, |
@@ -311,12 +311,12 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function getUserByRecaller($recaller) |
313 | 313 | { |
314 | - if ($this->validRecaller($recaller) && ! $this->tokenRetrievalAttempted) { |
|
314 | + if ($this->validRecaller($recaller) && !$this->tokenRetrievalAttempted) { |
|
315 | 315 | $this->tokenRetrievalAttempted = true; |
316 | 316 | |
317 | 317 | list($id, $token) = explode('|', $recaller, 2); |
318 | 318 | |
319 | - $this->viaRemember = ! is_null($user = $this->provider->retrieveByToken($id, $token)); |
|
319 | + $this->viaRemember = !is_null($user = $this->provider->retrieveByToken($id, $token)); |
|
320 | 320 | |
321 | 321 | return $user; |
322 | 322 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | */ |
362 | 362 | protected function hasValidCredentials($user, $credentials) |
363 | 363 | { |
364 | - return !is_null($user) && Hash::check($credentials['password'], $user->password); |
|
364 | + return !is_null($user) && Hash::check($credentials[ 'password' ], $user->password); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -373,12 +373,12 @@ discard block |
||
373 | 373 | */ |
374 | 374 | protected function validRecaller($recaller) |
375 | 375 | { |
376 | - if (! is_string($recaller) || ! (new StringObject($recaller))->contains('|')) { |
|
376 | + if (!is_string($recaller) || !(new StringObject($recaller))->contains('|')) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | 380 | $segments = explode('|', $recaller); |
381 | 381 | |
382 | - return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== ''; |
|
382 | + return count($segments) == 2 && trim($segments[ 0 ]) !== '' && trim($segments[ 1 ]) !== ''; |
|
383 | 383 | } |
384 | 384 | } |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | * @param array $oldValues |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public function showLoginForm($errors = null, array $oldValues = []) |
|
49 | + public function showLoginForm($errors = null, array $oldValues = [ ]) |
|
50 | 50 | { |
51 | - return view("auth/login", ["errors" => $errors, 'old' => $oldValues]); |
|
51 | + return view("auth/login", [ "errors" => $errors, 'old' => $oldValues ]); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function getPasswordReset() |
67 | 67 | { |
68 | 68 | // check if user is authenticated redirect to login if not |
69 | - if(! Auth::check()) { |
|
69 | + if (!Auth::check()) { |
|
70 | 70 | header("Location: /login"); |
71 | 71 | exit; |
72 | 72 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | // gets passed from register flow. So we need to |
96 | 96 | // remove it to successfully login. I dont understand |
97 | 97 | // why but that is how we do it |
98 | - unset($credentials['name']); |
|
99 | - unset($credentials['remember']); |
|
98 | + unset($credentials[ 'name' ]); |
|
99 | + unset($credentials[ 'remember' ]); |
|
100 | 100 | |
101 | 101 | $remember = $request->param("remember") ?: false; |
102 | 102 | |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | |
144 | 144 | if ($request->method() === 'GET') { |
145 | 145 | // show reset password view |
146 | - return view("auth/passwords/reset", ['token' => $token]); |
|
146 | + return view("auth/passwords/reset", [ 'token' => $token ]); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $passwordConfirmation = $request->paramsPost()->get("password_confirmation"); |
150 | 150 | $password = $request->paramsPost()->get("password"); |
151 | - $errors = arr([]); |
|
151 | + $errors = arr([ ]); |
|
152 | 152 | |
153 | 153 | if ($password !== $passwordConfirmation) { |
154 | 154 | $errors->append("password_confirmation", "Passwords do not match"); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $errors->removeIfValue(true); |
165 | 165 | |
166 | 166 | if ($errors->count() > 0) { |
167 | - return view("auth/passwords/reset", ["errors" => $errors]); |
|
167 | + return view("auth/passwords/reset", [ "errors" => $errors ]); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | // now everything is fine and the password can be set |
@@ -76,16 +76,16 @@ |
||
76 | 76 | handle($e); |
77 | 77 | } |
78 | 78 | |
79 | - if (! $key->contains("password")) { |
|
79 | + if (!$key->contains("password")) { |
|
80 | 80 | $prepend = (0 < $i ? ", " : ""); |
81 | 81 | |
82 | - $query .= $prepend. $key ."='". $value."'"; |
|
82 | + $query .= $prepend.$key."='".$value."'"; |
|
83 | 83 | |
84 | 84 | $i++; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - return DB::select($query)[0]; |
|
88 | + return DB::select($query)[ 0 ]; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -51,15 +51,17 @@ |
||
51 | 51 | |
52 | 52 | $template = str_replace("§NAME§", $migrationName, $this->template); |
53 | 53 | |
54 | - if(isset($connectionName)) |
|
55 | - $template = str_replace("§CONNECTION§", 'protected $connection = "'.$connectionName.'";', $template); |
|
56 | - else |
|
57 | - $template = str_replace("§CONNECTION§", '', $template); |
|
54 | + if(isset($connectionName)) { |
|
55 | + $template = str_replace("§CONNECTION§", 'protected $connection = "'.$connectionName.'";', $template); |
|
56 | + } else { |
|
57 | + $template = str_replace("§CONNECTION§", '', $template); |
|
58 | + } |
|
58 | 59 | |
59 | - if(isset($tableName)) |
|
60 | - $template = str_replace("§TABLE§", 'protected $table = "'.$tableName.'";', $template); |
|
61 | - else |
|
62 | - $template = str_replace("§TABLE§", '', $template); |
|
60 | + if(isset($tableName)) { |
|
61 | + $template = str_replace("§TABLE§", 'protected $table = "'.$tableName.'";', $template); |
|
62 | + } else { |
|
63 | + $template = str_replace("§TABLE§", '', $template); |
|
64 | + } |
|
63 | 65 | |
64 | 66 | $File = new File($migrationName.".php", new Storage("model"), true); |
65 | 67 | //$File->setContents($template); |
@@ -72,7 +72,7 @@ |
||
72 | 72 | try { |
73 | 73 | $File = new File($newMigrationName.".php", new Storage("migrations"), true); |
74 | 74 | |
75 | - if(fopen($File->getAbsolutePath(), "w")) { |
|
75 | + if (fopen($File->getAbsolutePath(), "w")) { |
|
76 | 76 | $tempDefaultCommand = str_replace("§NAME§", $newMigrationName, $this->template); |
77 | 77 | $tempDefaultCommand = str_replace("§connection§", $connection, $tempDefaultCommand); |
78 | 78 | file_put_contents($File->getAbsolutePath(), $tempDefaultCommand); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $original = $query->columns; |
55 | 55 | |
56 | 56 | if (is_null($query->columns)) { |
57 | - $query->columns = ['*']; |
|
57 | + $query->columns = [ '*' ]; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // To compile the query, we'll spin through each component of the query and |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | // basic routine regardless of an amount of records given to us to insert. |
96 | 96 | $table = $this->wrapTable($query->from); |
97 | 97 | |
98 | - if (! is_array(reset($values))) { |
|
99 | - $values = [$values]; |
|
98 | + if (!is_array(reset($values))) { |
|
99 | + $values = [ $values ]; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $columns = $this->columnize(array_keys(reset($values))); |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | // We need to build a list of parameter place-holders of values that are bound |
105 | 105 | // to the query. Each insert should have the exact same amount of parameter |
106 | 106 | // bindings so we will loop through the record and parameterize them all. |
107 | - $parameters = []; |
|
107 | + $parameters = [ ]; |
|
108 | 108 | |
109 | 109 | foreach ($values as $record) { |
110 | - $parameters[] = '('.$this->parameterize($record).')'; |
|
110 | + $parameters[ ] = '('.$this->parameterize($record).')'; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $parameters = implode(', ', $parameters); |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function compileUpdate(Builder $query, array $values): string |
126 | 126 | { |
127 | - $table = $this->wrapTable($query->from); |
|
127 | + $table = $this->wrapTable($query->from); |
|
128 | 128 | |
129 | 129 | // Each one of the columns in the update statements needs to be wrapped in the |
130 | 130 | // keyword identifiers, also a place-holder needs to be created for each of |
131 | 131 | // the values in the list of bindings so we can make the sets statements. |
132 | - $columns = []; |
|
132 | + $columns = [ ]; |
|
133 | 133 | |
134 | 134 | foreach ($values as $key => $value) { |
135 | 135 | $param = $this->parameter($value); |
136 | 136 | $param = is_string($param) ? "'".$param."'" : $param; |
137 | 137 | |
138 | - $columns[] = $this->wrap($key)." = ".$param; |
|
138 | + $columns[ ] = $this->wrap($key)." = ".$param; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $columns = implode(', ', $columns); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function compileTruncate(Builder $query) |
173 | 173 | { |
174 | - return ['truncate '.$this->wrapTable($query->from) => []]; |
|
174 | + return [ 'truncate '.$this->wrapTable($query->from) => [ ] ]; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function compileComponents(Builder $query) |
184 | 184 | { |
185 | - $sql = []; |
|
185 | + $sql = [ ]; |
|
186 | 186 | |
187 | 187 | foreach ($this->selectComponents as $component) { |
188 | 188 | // To compile the query, we'll spin through each component of the query and |
189 | 189 | // see if that component exists. If it does we'll just call the compiler |
190 | 190 | // function for the component which is responsible for making the SQL. |
191 | 191 | if (!is_null($query->$component)) { |
192 | - $method = 'compile' . ucfirst($component); |
|
192 | + $method = 'compile'.ucfirst($component); |
|
193 | 193 | |
194 | - $sql[$component] = $this->$method($query, $query->$component); |
|
194 | + $sql[ $component ] = $this->$method($query, $query->$component); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | $select = $query->distinct ? 'select distinct ' : 'select '; |
218 | 218 | |
219 | - return $select . $this->columnize($columns); |
|
219 | + return $select.$this->columnize($columns); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | protected function compileFrom(Builder $query, $table) |
230 | 230 | { |
231 | - return 'from ' . $this->wrapTable($table); |
|
231 | + return 'from '.$this->wrapTable($table); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | */ |
240 | 240 | protected function compileWheres(Builder $query) |
241 | 241 | { |
242 | - $sql = []; |
|
242 | + $sql = [ ]; |
|
243 | 243 | |
244 | 244 | if (is_null($query->wheres)) { |
245 | 245 | return ''; |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | // for actually creating the where clauses SQL. This helps keep the code nice |
250 | 250 | // and maintainable since each clause has a very small method that it uses. |
251 | 251 | foreach ($query->wheres as $where) { |
252 | - $method = "where{$where['type']}"; |
|
252 | + $method = "where{$where[ 'type' ]}"; |
|
253 | 253 | |
254 | - $sql[] = $where['boolean'].' '.$this->$method($query, $where); |
|
254 | + $sql[ ] = $where[ 'boolean' ].' '.$this->$method($query, $where); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | // If we actually have some where clauses, we will strip off the first boolean |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | */ |
276 | 276 | protected function compileOrders(Builder $query, $orders) |
277 | 277 | { |
278 | - return 'order by '.implode(', ', $orders[0])." ".$orders[1]; |
|
278 | + return 'order by '.implode(', ', $orders[ 0 ])." ".$orders[ 1 ]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function compileAggregate(Builder $query, $aggregate) |
301 | 301 | { |
302 | - $column = $this->columnize($aggregate['columns']); |
|
302 | + $column = $this->columnize($aggregate[ 'columns' ]); |
|
303 | 303 | |
304 | 304 | // If the query has a "distinct" constraint and we're not asking for all columns |
305 | 305 | // we need to prepend "distinct" onto the column name so that the query takes |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $column = 'distinct '.$column; |
309 | 309 | } |
310 | 310 | |
311 | - return 'select '.$aggregate['function'].'('.$column.') as aggregate'; |
|
311 | + return 'select '.$aggregate[ 'function' ].'('.$column.') as aggregate'; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function whereBasic(Builder $query, $where) |
340 | 340 | { |
341 | - $value = $this->parameter($where['value']); |
|
341 | + $value = $this->parameter($where[ 'value' ]); |
|
342 | 342 | |
343 | - return $this->wrap($where['column']).' '.$where['operator'].' '.$value; |
|
343 | + return $this->wrap($where[ 'column' ]).' '.$where[ 'operator' ].' '.$value; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | */ |
353 | 353 | protected function whereBetween(Builder $query, $where) |
354 | 354 | { |
355 | - $between = $where['not'] ? 'not between' : 'between'; |
|
355 | + $between = $where[ 'not' ] ? 'not between' : 'between'; |
|
356 | 356 | |
357 | - return $this->wrap($where['column']).' '.$between.' ? and ?'; |
|
357 | + return $this->wrap($where[ 'column' ]).' '.$between.' ? and ?'; |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -366,18 +366,18 @@ discard block |
||
366 | 366 | */ |
367 | 367 | protected function whereIn(Builder $query, $where) |
368 | 368 | { |
369 | - $in = $where['not'] ? 'not in' : 'in'; |
|
369 | + $in = $where[ 'not' ] ? 'not in' : 'in'; |
|
370 | 370 | |
371 | 371 | $values = " ("; |
372 | 372 | |
373 | 373 | $count = count($query->getBindings()); |
374 | 374 | for ($i = 1; $i <= $count; $i++) { |
375 | - $append = ($count > $i) ? "," : ""; |
|
376 | - $values .= "?" . $append; |
|
375 | + $append = ($count > $i) ? "," : ""; |
|
376 | + $values .= "?".$append; |
|
377 | 377 | } |
378 | 378 | $values .= ")"; |
379 | 379 | |
380 | - return $this->wrap($where['column']). ' '.$in.$values; |
|
380 | + return $this->wrap($where[ 'column' ]).' '.$in.$values; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | */ |
390 | 390 | protected function whereNull(Builder $query, $where) |
391 | 391 | { |
392 | - $null = $where['not'] ? 'is not null' : 'is null'; |
|
392 | + $null = $where[ 'not' ] ? 'is not null' : 'is null'; |
|
393 | 393 | |
394 | - return $this->wrap($where['column']). ' '.$null; |
|
394 | + return $this->wrap($where[ 'column' ]).' '.$null; |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | */ |
404 | 404 | protected function whereDate(Builder $builder, $where) |
405 | 405 | { |
406 | - return $this->wrap($where['column']).$where['operator'].$where['value']; |
|
406 | + return $this->wrap($where[ 'column' ]).$where[ 'operator' ].$where[ 'value' ]; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | */ |
416 | 416 | protected function whereYear(Builder $builder, $where) |
417 | 417 | { |
418 | - return "year(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
418 | + return "year(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | protected function whereMonth(Builder $builder, $where) |
429 | 429 | { |
430 | - return "month(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
430 | + return "month(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | */ |
440 | 440 | protected function whereDay(Builder $builder, $where) |
441 | 441 | { |
442 | - return "day(".$this->wrap($where['column']).")".$where['operator'].$where['value']; |
|
442 | + return "day(".$this->wrap($where[ 'column' ]).")".$where[ 'operator' ].$where[ 'value' ]; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | */ |
451 | 451 | protected function concatenate($segments) |
452 | 452 | { |
453 | - return implode(' ', array_filter($segments, function ($value) { |
|
454 | - return (string)$value !== ''; |
|
453 | + return implode(' ', array_filter($segments, function($value) { |
|
454 | + return (string) $value !== ''; |
|
455 | 455 | })); |
456 | 456 | } |
457 | 457 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | */ |
464 | 464 | public function columnize(array $columns) |
465 | 465 | { |
466 | - return implode(', ', array_map([$this, 'wrap'], $columns)); |
|
466 | + return implode(', ', array_map([ $this, 'wrap' ], $columns)); |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | /** |
@@ -474,10 +474,10 @@ discard block |
||
474 | 474 | */ |
475 | 475 | public function parameterize(array $values) |
476 | 476 | { |
477 | - $val = array_map([$this, 'parameter'], $values); |
|
477 | + $val = array_map([ $this, 'parameter' ], $values); |
|
478 | 478 | |
479 | 479 | foreach ($val as $key => $item) { |
480 | - $val[$key] = $this->quoteString($item); |
|
480 | + $val[ $key ] = $this->quoteString($item); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | return implode(', ', $val); |
@@ -485,11 +485,11 @@ discard block |
||
485 | 485 | |
486 | 486 | public function parameterizeForUpdate(array $columns, array $values) |
487 | 487 | { |
488 | - $queryValues = []; |
|
488 | + $queryValues = [ ]; |
|
489 | 489 | |
490 | 490 | $count = count($values); |
491 | 491 | for ($i = 0; $i < $count; $i++) { |
492 | - $queryValues[] = $columns[$i]."=".$this->quoteString(array_values($values)[$i]); |
|
492 | + $queryValues[ ] = $columns[ $i ]."=".$this->quoteString(array_values($values)[ $i ]); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | return implode(", ", $queryValues); |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | public function quoteString($value) |
516 | 516 | { |
517 | 517 | if (is_array($value)) { |
518 | - return implode(', ', array_map([$this, __FUNCTION__], $value)); |
|
518 | + return implode(', ', array_map([ $this, __FUNCTION__ ], $value)); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | return "'$value'"; |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | public function wrapTable($table) |
531 | 531 | { |
532 | 532 | if (!$this->isExpression($table)) { |
533 | - return $this->wrap($this->tablePrefix . $table, true); |
|
533 | + return $this->wrap($this->tablePrefix.$table, true); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | return $this->getValue($table); |
@@ -556,13 +556,13 @@ discard block |
||
556 | 556 | $segments = explode(' ', $value); |
557 | 557 | |
558 | 558 | if ($prefixAlias) { |
559 | - $segments[2] = $this->tablePrefix.$segments[2]; |
|
559 | + $segments[ 2 ] = $this->tablePrefix.$segments[ 2 ]; |
|
560 | 560 | } |
561 | 561 | |
562 | - return $this->wrap($segments[0]).' as '.$this->wrapValue($segments[2]); |
|
562 | + return $this->wrap($segments[ 0 ]).' as '.$this->wrapValue($segments[ 2 ]); |
|
563 | 563 | } |
564 | 564 | |
565 | - $wrapped = []; |
|
565 | + $wrapped = [ ]; |
|
566 | 566 | |
567 | 567 | $segments = explode('.', $value); |
568 | 568 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | // segments as if it was a table and the rest as just regular values. |
572 | 572 | foreach ($segments as $key => $segment) { |
573 | 573 | if ($key == 0 && count($segments) > 1) { |
574 | - $wrapped[] = $this->wrapTable($segment); |
|
574 | + $wrapped[ ] = $this->wrapTable($segment); |
|
575 | 575 | } else { |
576 | - $wrapped[] = $this->wrapValue($segment); |
|
576 | + $wrapped[ ] = $this->wrapValue($segment); |
|
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
@@ -595,11 +595,11 @@ discard block |
||
595 | 595 | // as well in order to generate proper syntax. If this is a column of course |
596 | 596 | // no prefix is necessary. The condition will be true when from wrapTable. |
597 | 597 | if ($prefixAlias) { |
598 | - $segments[1] = $this->tablePrefix . $segments[1]; |
|
598 | + $segments[ 1 ] = $this->tablePrefix.$segments[ 1 ]; |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | return $this->wrap( |
602 | - $segments[0]) . ' as ' . $this->wrapValue($segments[1] |
|
602 | + $segments[ 0 ]).' as '.$this->wrapValue($segments[ 1 ] |
|
603 | 603 | ); |
604 | 604 | } |
605 | 605 | |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | */ |
612 | 612 | protected function wrapSegments($segments) |
613 | 613 | { |
614 | - return arr($segments)->map(function ($segment, $key) use ($segments) { |
|
614 | + return arr($segments)->map(function($segment, $key) use ($segments) { |
|
615 | 615 | return $key == 0 && count($segments) > 1 |
616 | 616 | ? $this->wrapTable($segment) |
617 | 617 | : $this->wrapValue($segment); |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | protected function wrapValue($value) |
628 | 628 | { |
629 | 629 | if ($value !== '*') { |
630 | - return '`' . str_replace('"', '""', $value) . '`'; |
|
630 | + return '`'.str_replace('"', '""', $value).'`'; |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | return $value; |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | * @var array |
50 | 50 | */ |
51 | 51 | protected $bindings = [ |
52 | - 'select' => [], |
|
53 | - 'join' => [], |
|
54 | - 'where' => [], |
|
55 | - 'having' => [], |
|
56 | - 'order' => [], |
|
57 | - 'union' => [], |
|
52 | + 'select' => [ ], |
|
53 | + 'join' => [ ], |
|
54 | + 'where' => [ ], |
|
55 | + 'having' => [ ], |
|
56 | + 'order' => [ ], |
|
57 | + 'union' => [ ], |
|
58 | 58 | ]; |
59 | 59 | |
60 | 60 | /** |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected function addArrayOfWheres($column, string $boolean) |
143 | 143 | { |
144 | - return $this->whereNested(function ($query) use ($column) { |
|
144 | + return $this->whereNested(function($query) use ($column) { |
|
145 | 145 | |
146 | 146 | /** @var Builder $query */ |
147 | 147 | foreach ($column as $key => $value) { |
148 | 148 | if (is_numeric($key) && is_array($value)) { |
149 | - call_user_func_array([$query, 'where'], $value); |
|
149 | + call_user_func_array([ $query, 'where' ], $value); |
|
150 | 150 | } else { |
151 | 151 | $query->where($key, '=', $value); |
152 | 152 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function addBinding($value, $type = 'where') |
207 | 207 | { |
208 | - if (! array_key_exists($type, $this->bindings)) { |
|
208 | + if (!array_key_exists($type, $this->bindings)) { |
|
209 | 209 | throw new InvalidArgumentException("Invalid binding type: {$type}."); |
210 | 210 | } |
211 | 211 | |
212 | 212 | if (is_array($value)) { |
213 | - $this->bindings[$type] = array_values(array_merge($this->bindings[$type], $value)); |
|
213 | + $this->bindings[ $type ] = array_values(array_merge($this->bindings[ $type ], $value)); |
|
214 | 214 | } else { |
215 | - $this->bindings[$type][] = $value; |
|
215 | + $this->bindings[ $type ][ ] = $value; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | return $this; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param array|mixed $columns |
246 | 246 | * @return $this |
247 | 247 | */ |
248 | - public function select($columns = ['*']) |
|
248 | + public function select($columns = [ '*' ]) |
|
249 | 249 | { |
250 | 250 | $this->columns = is_array($columns) ? $columns : func_get_args(); |
251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @param array $bindings |
258 | 258 | * @return mixed |
259 | 259 | */ |
260 | - public function selectRaw(string $query, array $bindings = []) |
|
260 | + public function selectRaw(string $query, array $bindings = [ ]) |
|
261 | 261 | { |
262 | 262 | return $this->connection->select($query, $bindings); |
263 | 263 | } |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | return true; |
273 | 273 | } |
274 | 274 | |
275 | - if (! is_array(reset($values))) { |
|
276 | - $values = [$values]; |
|
275 | + if (!is_array(reset($values))) { |
|
276 | + $values = [ $values ]; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // Here, we will sort the insert keys for every record so that each insert is |
@@ -282,18 +282,18 @@ discard block |
||
282 | 282 | else { |
283 | 283 | foreach ($values as $key => $value) { |
284 | 284 | ksort($value); |
285 | - $values[$key] = $value; |
|
285 | + $values[ $key ] = $value; |
|
286 | 286 | } |
287 | 287 | } |
288 | 288 | |
289 | 289 | // We'll treat every insert like a batch insert so we can easily insert each |
290 | 290 | // of the records into the database consistently. This will make it much |
291 | 291 | // easier on the grammars to just handle one type of record insertion. |
292 | - $bindings = []; |
|
292 | + $bindings = [ ]; |
|
293 | 293 | |
294 | 294 | foreach ($values as $record) { |
295 | 295 | foreach ($record as $value) { |
296 | - $bindings[] = $value; |
|
296 | + $bindings[ ] = $value; |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | { |
349 | 349 | $wrapped = $this->grammar->wrap($column); |
350 | 350 | |
351 | - $columns = array_merge([$column => $this->raw("$wrapped + $amount")]); |
|
351 | + $columns = array_merge([ $column => $this->raw("$wrapped + $amount") ]); |
|
352 | 352 | |
353 | 353 | return $this->update($columns); |
354 | 354 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | { |
365 | 365 | $wrapped = $this->grammar->wrap($column); |
366 | 366 | |
367 | - $columns = array_merge([$column => $this->raw("$wrapped - $amount")]); |
|
367 | + $columns = array_merge([ $column => $this->raw("$wrapped - $amount") ]); |
|
368 | 368 | |
369 | 369 | return $this->update($columns); |
370 | 370 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | // If an ID is passed to the method, we will set the where clause to check |
381 | 381 | // the ID to allow developers to simply and quickly remove a single row |
382 | 382 | // from their database without manually specifying the where clauses. |
383 | - if (! is_null($id)) { |
|
383 | + if (!is_null($id)) { |
|
384 | 384 | $this->where('id', '=', $id); |
385 | 385 | } |
386 | 386 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @param array $bindings |
407 | 407 | * @return bool |
408 | 408 | */ |
409 | - public function insertRaw(string $query, array $bindings = []) |
|
409 | + public function insertRaw(string $query, array $bindings = [ ]) |
|
410 | 410 | { |
411 | 411 | return $this->connection->insert($query, $bindings); |
412 | 412 | } |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param array $bindings |
417 | 417 | * @return int |
418 | 418 | */ |
419 | - public function updateRaw(string $query, array $bindings = []) |
|
419 | + public function updateRaw(string $query, array $bindings = [ ]) |
|
420 | 420 | { |
421 | 421 | return $this->connection->update($query, $bindings); |
422 | 422 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param array $bindings |
427 | 427 | * @return int |
428 | 428 | */ |
429 | - public function deleteRaw(string $query, array $bindings = []) |
|
429 | + public function deleteRaw(string $query, array $bindings = [ ]) |
|
430 | 430 | { |
431 | 431 | return $this->connection->delete($query, $bindings); |
432 | 432 | } |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | // passed to the method, we will assume that the operator is an equals sign |
467 | 467 | // and keep going. Otherwise, we'll require the operator to be passed in. |
468 | 468 | if (func_num_args() == 2) { |
469 | - list($value, $operator) = [$operator, '=']; |
|
469 | + list($value, $operator) = [ $operator, '=' ]; |
|
470 | 470 | } elseif ($this->invalidOperatorAndValue($operator, $value)) { |
471 | 471 | throw new InvalidArgumentException('Illegal operator and value combination.'); |
472 | 472 | } |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | // If the given operator is not found in the list of valid operators we will |
475 | 475 | // assume that the developer is just short-cutting the '=' operators and |
476 | 476 | // we will set the operators to '=' and set the values appropriately. |
477 | - if (! in_array(strtolower($operator), $this->operators, true)) { |
|
478 | - list($value, $operator) = [$operator, '=']; |
|
477 | + if (!in_array(strtolower($operator), $this->operators, true)) { |
|
478 | + list($value, $operator) = [ $operator, '=' ]; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // If the value is a Closure, it means the developer is performing an entire |
@@ -497,9 +497,9 @@ discard block |
||
497 | 497 | // will be bound to each SQL statements when it is finally executed. |
498 | 498 | $type = 'Basic'; |
499 | 499 | |
500 | - $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
500 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'value', 'boolean'); |
|
501 | 501 | |
502 | - if (! $value instanceof Expression) { |
|
502 | + if (!$value instanceof Expression) { |
|
503 | 503 | $this->addBinding($value, 'where'); |
504 | 504 | } |
505 | 505 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | { |
520 | 520 | $type = 'in'; |
521 | 521 | |
522 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
522 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
523 | 523 | |
524 | 524 | $this->addBinding($values, 'where'); |
525 | 525 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | { |
577 | 577 | $type = 'between'; |
578 | 578 | |
579 | - $this->wheres[] = compact('column', 'type', 'boolean', 'not'); |
|
579 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'not'); |
|
580 | 580 | |
581 | 581 | $this->addBinding($values, 'where'); |
582 | 582 | |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | if (count($query->wheres)) { |
661 | 661 | $type = 'Nested'; |
662 | 662 | |
663 | - $this->wheres[] = compact('type', 'query', 'boolean'); |
|
663 | + $this->wheres[ ] = compact('type', 'query', 'boolean'); |
|
664 | 664 | |
665 | 665 | $this->addBinding($query->getBindings(), 'where'); |
666 | 666 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | // in the array of where clauses for the "main" parent query instance. |
689 | 689 | call_user_func($callback, $query); |
690 | 690 | |
691 | - $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
691 | + $this->wheres[ ] = compact('type', 'column', 'operator', 'query', 'boolean'); |
|
692 | 692 | |
693 | 693 | $this->addBinding($query->getBindings(), 'where'); |
694 | 694 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | { |
708 | 708 | $type = 'Null'; |
709 | 709 | |
710 | - $this->wheres[] = compact('type', 'column', 'boolean', 'not'); |
|
710 | + $this->wheres[ ] = compact('type', 'column', 'boolean', 'not'); |
|
711 | 711 | |
712 | 712 | return $this; |
713 | 713 | } |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | protected function addDateBasedWhere($type, $column, $operator, $value, $boolean = 'and') |
829 | 829 | { |
830 | - $this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
830 | + $this->wheres[ ] = compact('column', 'type', 'boolean', 'operator', 'value'); |
|
831 | 831 | |
832 | 832 | $this->addBinding($value, 'where'); |
833 | 833 | |
@@ -843,11 +843,11 @@ discard block |
||
843 | 843 | */ |
844 | 844 | public function orderBy($column, $direction = 'asc') |
845 | 845 | { |
846 | - if(!($direction == 'asc' or $direction == 'desc')) { |
|
846 | + if (!($direction == 'asc' or $direction == 'desc')) { |
|
847 | 847 | handle(new Exception("Order by direction invalid: '".$direction."'")); |
848 | 848 | } |
849 | 849 | |
850 | - $column = is_array($column) ? $column : [$column]; |
|
850 | + $column = is_array($column) ? $column : [ $column ]; |
|
851 | 851 | |
852 | 852 | $this->orders = [ |
853 | 853 | $column, |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | * @param array $columns |
892 | 892 | * @return ArrayObject|null |
893 | 893 | */ |
894 | - public function get(array $columns = ['*']) |
|
894 | + public function get(array $columns = [ '*' ]) |
|
895 | 895 | { |
896 | 896 | $this->columns = $columns; |
897 | 897 | |
@@ -956,11 +956,11 @@ discard block |
||
956 | 956 | * @param array $columns |
957 | 957 | * @return Model |
958 | 958 | */ |
959 | - public function first(array $columns = ['*']) |
|
959 | + public function first(array $columns = [ '*' ]) |
|
960 | 960 | { |
961 | 961 | $this->limit(1); |
962 | 962 | |
963 | - return $this->get($columns)[0]; |
|
963 | + return $this->get($columns)[ 0 ]; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | /** |
@@ -971,7 +971,7 @@ discard block |
||
971 | 971 | */ |
972 | 972 | public function value(string $val) |
973 | 973 | { |
974 | - return $this->first([$val])->$val; |
|
974 | + return $this->first([ $val ])->$val; |
|
975 | 975 | } |
976 | 976 | |
977 | 977 | /** |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | */ |
983 | 983 | public function count($columns = '*') |
984 | 984 | { |
985 | - if (! is_array($columns)) { |
|
986 | - $columns = [$columns]; |
|
985 | + if (!is_array($columns)) { |
|
986 | + $columns = [ $columns ]; |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | return (int) $this->aggregate(__FUNCTION__, $columns); |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | */ |
998 | 998 | public function min(string $column) |
999 | 999 | { |
1000 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1000 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | /** |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | */ |
1009 | 1009 | public function max($column) |
1010 | 1010 | { |
1011 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1011 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | */ |
1020 | 1020 | public function sum($column) |
1021 | 1021 | { |
1022 | - $result = $this->aggregate(__FUNCTION__, [$column]); |
|
1022 | + $result = $this->aggregate(__FUNCTION__, [ $column ]); |
|
1023 | 1023 | |
1024 | 1024 | return $result ?: 0; |
1025 | 1025 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | public function avg($column) |
1034 | 1034 | { |
1035 | - return $this->aggregate(__FUNCTION__, [$column]); |
|
1035 | + return $this->aggregate(__FUNCTION__, [ $column ]); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | /** |
@@ -1067,10 +1067,10 @@ discard block |
||
1067 | 1067 | |
1068 | 1068 | $results = $this->connection->select($sql); |
1069 | 1069 | |
1070 | - if (isset($results[0])) { |
|
1071 | - $results = (array) $results[0]; |
|
1070 | + if (isset($results[ 0 ])) { |
|
1071 | + $results = (array) $results[ 0 ]; |
|
1072 | 1072 | |
1073 | - return (bool) $results['exists']; |
|
1073 | + return (bool) $results[ 'exists' ]; |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | return false; |
@@ -1083,7 +1083,7 @@ discard block |
||
1083 | 1083 | */ |
1084 | 1084 | public function doesntExist() |
1085 | 1085 | { |
1086 | - return ! $this->exists(); |
|
1086 | + return !$this->exists(); |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | /** |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @param array $columns |
1094 | 1094 | * @return float|int |
1095 | 1095 | */ |
1096 | - public function aggregate($function, $columns = ['*']) |
|
1096 | + public function aggregate($function, $columns = [ '*' ]) |
|
1097 | 1097 | { |
1098 | 1098 | $this->aggregate = compact('function', 'columns'); |
1099 | 1099 | |
@@ -1108,10 +1108,10 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | $this->columns = $previousColumns; |
1110 | 1110 | |
1111 | - if (isset($results[0])) { |
|
1112 | - $result = array_change_key_case((array) $results[0]); |
|
1111 | + if (isset($results[ 0 ])) { |
|
1112 | + $result = array_change_key_case((array) $results[ 0 ]); |
|
1113 | 1113 | |
1114 | - return $result['aggregate']; |
|
1114 | + return $result[ 'aggregate' ]; |
|
1115 | 1115 | } |
1116 | 1116 | } |
1117 | 1117 | |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | private function isOperatorValid($operatorToCheck) |
1127 | 1127 | { |
1128 | 1128 | foreach ($this->operators as $operator) { |
1129 | - if($operatorToCheck === $operator) { |
|
1129 | + if ($operatorToCheck === $operator) { |
|
1130 | 1130 | return true; |
1131 | 1131 | } |
1132 | 1132 | } |
@@ -1152,8 +1152,8 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | protected function cleanBindings(array $bindings) |
1154 | 1154 | { |
1155 | - return array_values(array_filter($bindings, function ($binding) { |
|
1156 | - return ! $binding instanceof Expression; |
|
1155 | + return array_values(array_filter($bindings, function($binding) { |
|
1156 | + return !$binding instanceof Expression; |
|
1157 | 1157 | })); |
1158 | 1158 | } |
1159 | 1159 | |
@@ -1167,13 +1167,13 @@ discard block |
||
1167 | 1167 | protected function prepareRawQuery(string $query, array $bindings): string |
1168 | 1168 | { |
1169 | 1169 | // search for values in query |
1170 | - preg_match_all("/:([^ ]*)/", $query,$values); |
|
1170 | + preg_match_all("/:([^ ]*)/", $query, $values); |
|
1171 | 1171 | |
1172 | 1172 | // replace values with bindings |
1173 | - foreach ($values[1] as $value) { |
|
1173 | + foreach ($values[ 1 ] as $value) { |
|
1174 | 1174 | // check if fitting binding exists |
1175 | - if(array_key_exists($value, $bindings)) { |
|
1176 | - $query = str_replace(":".$value, $bindings[$value], $query); |
|
1175 | + if (array_key_exists($value, $bindings)) { |
|
1176 | + $query = str_replace(":".$value, $bindings[ $value ], $query); |
|
1177 | 1177 | } else { |
1178 | 1178 | handle(new Exception("Could not find fitting value '$value' in bindings for query: '$query'")); |
1179 | 1179 | } |
@@ -23,15 +23,15 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @var array |
25 | 25 | */ |
26 | - private $Instances = []; |
|
26 | + private $Instances = [ ]; |
|
27 | 27 | |
28 | - public function call($classMethod, $param = []) |
|
28 | + public function call($classMethod, $param = [ ]) |
|
29 | 29 | { |
30 | 30 | $method = null; |
31 | 31 | |
32 | 32 | $this->registerNewClass($classMethod, $method); |
33 | 33 | try { |
34 | - if($method == null) |
|
34 | + if ($method == null) |
|
35 | 35 | throw new Exception("You have to specify an method to call"); |
36 | 36 | } catch (Exception $e) { |
37 | 37 | handle($e); |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | $method = null; |
46 | 46 | $this->registerNewClass($className, $method); |
47 | 47 | |
48 | - return $this->Instances[$className]; |
|
48 | + return $this->Instances[ $className ]; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | private function checkIfClassIsRegistered($class) |
52 | 52 | { |
53 | - foreach($this->Instances as $Class){ |
|
54 | - if(get_class($Class) == $class){ |
|
53 | + foreach ($this->Instances as $Class) { |
|
54 | + if (get_class($Class) == $class) { |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | } |
@@ -60,33 +60,33 @@ discard block |
||
60 | 60 | |
61 | 61 | private function registerNewClass(&$class, &$method) |
62 | 62 | { |
63 | - $method = explode("@", $class)[1]; |
|
64 | - $class = self::validateClass(explode("@", $class)[0]); |
|
63 | + $method = explode("@", $class)[ 1 ]; |
|
64 | + $class = self::validateClass(explode("@", $class)[ 0 ]); |
|
65 | 65 | |
66 | 66 | try { |
67 | - if(! is_object($t_class = new $class)) |
|
67 | + if (!is_object($t_class = new $class)) |
|
68 | 68 | throw new Exception("Could not instantiate class"); |
69 | 69 | } catch (Exception $e) { |
70 | 70 | handle($e); |
71 | 71 | } finally { |
72 | - if(! self::checkIfClassIsRegistered($class)){ |
|
73 | - $this->Instances[$class] = new $class; |
|
72 | + if (!self::checkIfClassIsRegistered($class)) { |
|
73 | + $this->Instances[ $class ] = new $class; |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
78 | 78 | private function callMethod($class, $method, $param) |
79 | 79 | { |
80 | - return call_user_func_array(array($this->Instances[$class], $method), $param); |
|
80 | + return call_user_func_array(array($this->Instances[ $class ], $method), $param); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function validateClass($class) |
84 | 84 | { |
85 | 85 | try { |
86 | - foreach($this->defaultNamespaces as $namespace){ |
|
86 | + foreach ($this->defaultNamespaces as $namespace) { |
|
87 | 87 | //var_dump($namespace . "\\" . $class); |
88 | - if(class_exists($namespace . "\\" . $class)){ |
|
89 | - return $namespace . "\\" . $class; |
|
88 | + if (class_exists($namespace."\\".$class)) { |
|
89 | + return $namespace."\\".$class; |
|
90 | 90 | } elseif (class_exists($class)) { |
91 | 91 | return $class; |
92 | 92 | } |
@@ -31,8 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | $this->registerNewClass($classMethod, $method); |
33 | 33 | try { |
34 | - if($method == null) |
|
35 | - throw new Exception("You have to specify an method to call"); |
|
34 | + if($method == null) { |
|
35 | + throw new Exception("You have to specify an method to call"); |
|
36 | + } |
|
36 | 37 | } catch (Exception $e) { |
37 | 38 | handle($e); |
38 | 39 | } finally { |
@@ -64,8 +65,9 @@ discard block |
||
64 | 65 | $class = self::validateClass(explode("@", $class)[0]); |
65 | 66 | |
66 | 67 | try { |
67 | - if(! is_object($t_class = new $class)) |
|
68 | - throw new Exception("Could not instantiate class"); |
|
68 | + if(! is_object($t_class = new $class)) { |
|
69 | + throw new Exception("Could not instantiate class"); |
|
70 | + } |
|
69 | 71 | } catch (Exception $e) { |
70 | 72 | handle($e); |
71 | 73 | } finally { |