@@ -98,7 +98,9 @@ |
||
| 98 | 98 | */ |
| 99 | 99 | public function destroy() |
| 100 | 100 | { |
| 101 | - foreach (array_keys($this->all()) as $key) $this->remove($key); |
|
| 101 | + foreach (array_keys($this->all()) as $key) { |
|
| 102 | + $this->remove($key); |
|
| 103 | + } |
|
| 102 | 104 | unset($_COOKIE); |
| 103 | 105 | } |
| 104 | 106 | } |
@@ -120,17 +120,17 @@ |
||
| 120 | 120 | */ |
| 121 | 121 | private function parameters() |
| 122 | 122 | { |
| 123 | - $url = $this->app->request->url(); |
|
| 123 | + $url = $this->app->request->url(); |
|
| 124 | 124 | |
| 125 | - if ($url === '/') {return;} |
|
| 126 | - $parameters = explode('/', $url); |
|
| 125 | + if ($url === '/') {return; } |
|
| 126 | + $parameters = explode('/', $url); |
|
| 127 | 127 | array_shift($parameters); |
| 128 | 128 | $return = []; |
| 129 | 129 | |
| 130 | 130 | foreach ($parameters as $parameter) { |
| 131 | 131 | $name = $parameter; |
| 132 | - $length = strpos($url, $parameter) + strlen($parameter); |
|
| 133 | - $link = substr($url, 0, $length); |
|
| 132 | + $length = strpos($url, $parameter) + strlen($parameter); |
|
| 133 | + $link = substr($url, 0, $length); |
|
| 134 | 134 | |
| 135 | 135 | $return[] = [ |
| 136 | 136 | 'name' => $name, |
@@ -103,7 +103,9 @@ |
||
| 103 | 103 | $public = assets(); |
| 104 | 104 | $public = str_replace($dir, $host, $public); |
| 105 | 105 | $public = str_replace('\\', '/', $public); |
| 106 | - if (substr($public, -1) !== '/') $public = $public . '/'; |
|
| 106 | + if (substr($public, -1) !== '/') { |
|
| 107 | + $public = $public . '/'; |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | 110 | return $public; |
| 109 | 111 | } |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | return $this->container[$path . ':content']; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - /** |
|
| 116 | + /** |
|
| 117 | 117 | * Generate full path to the given path |
| 118 | 118 | * |
| 119 | 119 | * @param string $path |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | ini_set('session.use_only_cookies', 1); |
| 30 | 30 | |
| 31 | - if (! session_id()) session_start(); |
|
| 31 | + if (!session_id()) session_start(); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param mixed $default |
| 51 | 51 | * @return mixed |
| 52 | 52 | */ |
| 53 | - public function get($key , $default = null) |
|
| 53 | + public function get($key, $default = null) |
|
| 54 | 54 | { |
| 55 | 55 | return array_get($_SESSION, $key, $default); |
| 56 | 56 | } |
@@ -28,7 +28,9 @@ |
||
| 28 | 28 | { |
| 29 | 29 | ini_set('session.use_only_cookies', 1); |
| 30 | 30 | |
| 31 | - if (! session_id()) session_start(); |
|
| 31 | + if (! session_id()) { |
|
| 32 | + session_start(); |
|
| 33 | + } |
|
| 32 | 34 | } |
| 33 | 35 | |
| 34 | 36 | /** |
@@ -38,7 +38,9 @@ discard block |
||
| 38 | 38 | public function add($name, $link, $icon = null) |
| 39 | 39 | { |
| 40 | 40 | if (!$this->title) { |
| 41 | - if (!$icon) $icon = 'icon-star'; |
|
| 41 | + if (!$icon) { |
|
| 42 | + $icon = 'icon-star'; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | $this->pages[] = [ |
| 44 | 46 | 'name' => $name, |
@@ -46,7 +48,9 @@ discard block |
||
| 46 | 48 | 'icon' => $icon |
| 47 | 49 | ]; |
| 48 | 50 | } else { |
| 49 | - if (!$icon) $icon = $this->icon; |
|
| 51 | + if (!$icon) { |
|
| 52 | + $icon = $this->icon; |
|
| 53 | + } |
|
| 50 | 54 | |
| 51 | 55 | $page = [ |
| 52 | 56 | 'name' => $name, |
@@ -70,7 +74,9 @@ discard block |
||
| 70 | 74 | { |
| 71 | 75 | $this->title = $options['title']; |
| 72 | 76 | |
| 73 | - if (!$options['icon']) $options['icon'] = 'icon-star'; |
|
| 77 | + if (!$options['icon']) { |
|
| 78 | + $options['icon'] = 'icon-star'; |
|
| 79 | + } |
|
| 74 | 80 | |
| 75 | 81 | $this->icon = $options['icon']; |
| 76 | 82 | |
@@ -223,8 +223,8 @@ discard block |
||
| 223 | 223 | if ($start && $end) { |
| 224 | 224 | $year = DateTime::createFromFormat($format, $value)->format('Y'); |
| 225 | 225 | |
| 226 | - if ($year < $start || $year > $end) { |
|
| 227 | - $msg = $msg ?: 'this field must be between ' . $start . ' and ' . $end; |
|
| 226 | + if ($year < $start || $year > $end) { |
|
| 227 | + $msg = $msg ?: 'this field must be between ' . $start . ' and ' . $end; |
|
| 228 | 228 | |
| 229 | 229 | $this->addError($this->input, $msg); |
| 230 | 230 | |
@@ -370,14 +370,14 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | if (is_array($excepts->languages)) { |
| 373 | - foreach($excepts->languages as $language) { |
|
| 373 | + foreach ($excepts->languages as $language) { |
|
| 374 | 374 | $langsRegex .= $this->languages(trim($language)); |
| 375 | 375 | $languages .= "$language, "; |
| 376 | 376 | } |
| 377 | 377 | $languages = rtrim($languages, ", "); |
| 378 | 378 | } else if (is_string($excepts->languages)) { |
| 379 | 379 | if (preg_match('/,/', $excepts->languages) && preg_match_all('/,/', $excepts->languages)) { |
| 380 | - foreach(explode(',', $excepts->languages) as $language) { |
|
| 380 | + foreach (explode(',', $excepts->languages) as $language) { |
|
| 381 | 381 | $langsRegex .= $this->languages(trim($language)); |
| 382 | 382 | $languages .= "$language, "; |
| 383 | 383 | } |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $splitChars = str_split($splitChars); |
| 411 | 411 | $splitChars = "\\" . implode('|\\', $splitChars); |
| 412 | 412 | } |
| 413 | - $re2 = "/^($splitChars"."|\\s+\\$splitChars)/"; |
|
| 413 | + $re2 = "/^($splitChars" . "|\\s+\\$splitChars)/"; |
|
| 414 | 414 | if (preg_match_all($re2, $value)) { |
| 415 | 415 | $msg = $msg ?: 'charachters cant be in the first'; |
| 416 | 416 | |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | $splitChars = str_split($splitChars); |
| 426 | 426 | $splitChars = "\\" . implode('|\\', $splitChars); |
| 427 | 427 | } |
| 428 | - $re3 = "/($splitChars"."|\\$splitChars\\s+)$/"; |
|
| 428 | + $re3 = "/($splitChars" . "|\\$splitChars\\s+)$/"; |
|
| 429 | 429 | if (preg_match_all($re3, $value)) { |
| 430 | 430 | $msg = $msg ?: 'charachters cant be in the end'; |
| 431 | 431 | |
@@ -461,8 +461,8 @@ discard block |
||
| 461 | 461 | |
| 462 | 462 | $re5 = "/^[0-9\\s$chars$langsRegex]*$/u"; |
| 463 | 463 | if (!preg_match($re5, $value)) { |
| 464 | - $chars = explode('\\', $chars); |
|
| 465 | - $chars = implode('', $chars); |
|
| 464 | + $chars = explode('\\', $chars); |
|
| 465 | + $chars = implode('', $chars); |
|
| 466 | 466 | $chars = $chars ? "[ $chars ] and" : ''; |
| 467 | 467 | $languages = $languages ? "[ $languages ]" : ''; |
| 468 | 468 | $msg = $msg ?: "just $chars $languages letters can be used"; |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | $files = []; |
| 520 | 520 | $final = []; |
| 521 | 521 | |
| 522 | - foreach($characters as $key => $character) { |
|
| 522 | + foreach ($characters as $key => $character) { |
|
| 523 | 523 | if (strpos($character, 'path:') === 0) { |
| 524 | 524 | unset($characters[$key]); |
| 525 | 525 | |
@@ -71,7 +71,9 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function require($call = true, $msg = null) |
| 73 | 73 | { |
| 74 | - if ($call === false) return $this; |
|
| 74 | + if ($call === false) { |
|
| 75 | + return $this; |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | $value = $this->value(); |
| 77 | 79 | |
@@ -103,11 +105,15 @@ discard block |
||
| 103 | 105 | */ |
| 104 | 106 | public function email($call = true, $msg = null) |
| 105 | 107 | { |
| 106 | - if ($call === false) return $this; |
|
| 108 | + if ($call === false) { |
|
| 109 | + return $this; |
|
| 110 | + } |
|
| 107 | 111 | |
| 108 | 112 | $value = $this->value(); |
| 109 | 113 | |
| 110 | - if (!$value && $value != '0') return $this; |
|
| 114 | + if (!$value && $value != '0') { |
|
| 115 | + return $this; |
|
| 116 | + } |
|
| 111 | 117 | |
| 112 | 118 | if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { |
| 113 | 119 | $msg = $msg ?: 'e-mail is not valid'; |
@@ -126,11 +132,15 @@ discard block |
||
| 126 | 132 | */ |
| 127 | 133 | public function image($call = true, $msg = null) |
| 128 | 134 | { |
| 129 | - if ($call === false) return $this; |
|
| 135 | + if ($call === false) { |
|
| 136 | + return $this; |
|
| 137 | + } |
|
| 130 | 138 | |
| 131 | 139 | $file = $this->app->request->file($this->input); |
| 132 | 140 | |
| 133 | - if (!$file->exists()) return $this; |
|
| 141 | + if (!$file->exists()) { |
|
| 142 | + return $this; |
|
| 143 | + } |
|
| 134 | 144 | |
| 135 | 145 | if (!$file->isImage()) { |
| 136 | 146 | $msg = $msg ?: 'image is not valid'; |
@@ -149,11 +159,15 @@ discard block |
||
| 149 | 159 | */ |
| 150 | 160 | public function number($call = true, $msg = null) |
| 151 | 161 | { |
| 152 | - if ($call === false) return $this; |
|
| 162 | + if ($call === false) { |
|
| 163 | + return $this; |
|
| 164 | + } |
|
| 153 | 165 | |
| 154 | 166 | $value = $this->value(); |
| 155 | 167 | |
| 156 | - if (!$value && $value != '0') return $this; |
|
| 168 | + if (!$value && $value != '0') { |
|
| 169 | + return $this; |
|
| 170 | + } |
|
| 157 | 171 | |
| 158 | 172 | if (!is_numeric($value)) { |
| 159 | 173 | $msg = $msg ?: 'this field must be a number'; |
@@ -172,11 +186,15 @@ discard block |
||
| 172 | 186 | */ |
| 173 | 187 | public function float($call = true, $msg = null) |
| 174 | 188 | { |
| 175 | - if ($call === false) return $this; |
|
| 189 | + if ($call === false) { |
|
| 190 | + return $this; |
|
| 191 | + } |
|
| 176 | 192 | |
| 177 | 193 | $value = $this->value(); |
| 178 | 194 | |
| 179 | - if (!$value && $value != '0') return $this; |
|
| 195 | + if (!$value && $value != '0') { |
|
| 196 | + return $this; |
|
| 197 | + } |
|
| 180 | 198 | |
| 181 | 199 | if (!is_float($value)) { |
| 182 | 200 | $msg = $msg ?: "this field must be a float number"; |
@@ -197,11 +215,15 @@ discard block |
||
| 197 | 215 | */ |
| 198 | 216 | public function date($options = [], $msg = null) |
| 199 | 217 | { |
| 200 | - if ($options === false) return $this; |
|
| 218 | + if ($options === false) { |
|
| 219 | + return $this; |
|
| 220 | + } |
|
| 201 | 221 | |
| 202 | 222 | $value = $this->value(); |
| 203 | 223 | |
| 204 | - if (!$value && $value != '0') return $this; |
|
| 224 | + if (!$value && $value != '0') { |
|
| 225 | + return $this; |
|
| 226 | + } |
|
| 205 | 227 | |
| 206 | 228 | $options = json_encode($options); |
| 207 | 229 | $options = json_decode($options); |
@@ -267,11 +289,15 @@ discard block |
||
| 267 | 289 | */ |
| 268 | 290 | public function text($call = true, $msg = null) |
| 269 | 291 | { |
| 270 | - if ($call === false) return $this; |
|
| 292 | + if ($call === false) { |
|
| 293 | + return $this; |
|
| 294 | + } |
|
| 271 | 295 | |
| 272 | 296 | $value = $this->value(); |
| 273 | 297 | |
| 274 | - if (!$value && $value != '0') return $this; |
|
| 298 | + if (!$value && $value != '0') { |
|
| 299 | + return $this; |
|
| 300 | + } |
|
| 275 | 301 | |
| 276 | 302 | if (!is_string($value)) { |
| 277 | 303 | $msg = $msg ?: 'the field must be a text'; |
@@ -290,11 +316,15 @@ discard block |
||
| 290 | 316 | */ |
| 291 | 317 | public function noNumbers($call = true, $msg = null) |
| 292 | 318 | { |
| 293 | - if ($call === false) return $this; |
|
| 319 | + if ($call === false) { |
|
| 320 | + return $this; |
|
| 321 | + } |
|
| 294 | 322 | |
| 295 | 323 | $value = $this->value(); |
| 296 | 324 | |
| 297 | - if (!$value && $value != '0') return $this; |
|
| 325 | + if (!$value && $value != '0') { |
|
| 326 | + return $this; |
|
| 327 | + } |
|
| 298 | 328 | |
| 299 | 329 | if (preg_match('~[0-9]~', $value)) { |
| 300 | 330 | $msg = $msg ?: 'numbers are not allow'; |
@@ -327,11 +357,15 @@ discard block |
||
| 327 | 357 | */ |
| 328 | 358 | public function characters($excepts, $msg = null) |
| 329 | 359 | { |
| 330 | - if ($excepts === false) return $this; |
|
| 360 | + if ($excepts === false) { |
|
| 361 | + return $this; |
|
| 362 | + } |
|
| 331 | 363 | |
| 332 | 364 | $value = $this->value(); |
| 333 | 365 | |
| 334 | - if (!$value && $value != '0') return $this; |
|
| 366 | + if (!$value && $value != '0') { |
|
| 367 | + return $this; |
|
| 368 | + } |
|
| 335 | 369 | |
| 336 | 370 | $chars = ''; |
| 337 | 371 | $times = null; |
@@ -480,11 +514,15 @@ discard block |
||
| 480 | 514 | */ |
| 481 | 515 | public function noSpaces($call = true, $msg = null) |
| 482 | 516 | { |
| 483 | - if ($call === false) return $this; |
|
| 517 | + if ($call === false) { |
|
| 518 | + return $this; |
|
| 519 | + } |
|
| 484 | 520 | |
| 485 | 521 | $value = $this->value(); |
| 486 | 522 | |
| 487 | - if (!$value && $value != '0') return $this; |
|
| 523 | + if (!$value && $value != '0') { |
|
| 524 | + return $this; |
|
| 525 | + } |
|
| 488 | 526 | |
| 489 | 527 | if (preg_match('/\s/', $value)) { |
| 490 | 528 | $msg = $msg ?: 'spaces are not allow'; |
@@ -503,11 +541,15 @@ discard block |
||
| 503 | 541 | */ |
| 504 | 542 | public function containJust($characters = [], $msg = null) |
| 505 | 543 | { |
| 506 | - if ($characters === false) return $this; |
|
| 544 | + if ($characters === false) { |
|
| 545 | + return $this; |
|
| 546 | + } |
|
| 507 | 547 | |
| 508 | 548 | $value = $this->value(); |
| 509 | 549 | |
| 510 | - if (!$value && $value != '0') return $this; |
|
| 550 | + if (!$value && $value != '0') { |
|
| 551 | + return $this; |
|
| 552 | + } |
|
| 511 | 553 | |
| 512 | 554 | if (!is_array($characters) && $characters !== '') { |
| 513 | 555 | $characters = [$characters]; |
@@ -583,11 +625,15 @@ discard block |
||
| 583 | 625 | */ |
| 584 | 626 | public function length($length = null, $msg = null) |
| 585 | 627 | { |
| 586 | - if ($length === false) return $this; |
|
| 628 | + if ($length === false) { |
|
| 629 | + return $this; |
|
| 630 | + } |
|
| 587 | 631 | |
| 588 | 632 | $value = $this->value(); |
| 589 | 633 | |
| 590 | - if (!$value && $value != '0') return $this; |
|
| 634 | + if (!$value && $value != '0') { |
|
| 635 | + return $this; |
|
| 636 | + } |
|
| 591 | 637 | |
| 592 | 638 | if (strlen($value) !== $length) { |
| 593 | 639 | $msg = $msg ?: `this field can be just ${length} charachter`; |
@@ -606,11 +652,15 @@ discard block |
||
| 606 | 652 | */ |
| 607 | 653 | public function maxLen($length = null, $msg = null) |
| 608 | 654 | { |
| 609 | - if ($length === false) return $this; |
|
| 655 | + if ($length === false) { |
|
| 656 | + return $this; |
|
| 657 | + } |
|
| 610 | 658 | |
| 611 | 659 | $value = $this->value(); |
| 612 | 660 | |
| 613 | - if (!$value && $value != '0') return $this; |
|
| 661 | + if (!$value && $value != '0') { |
|
| 662 | + return $this; |
|
| 663 | + } |
|
| 614 | 664 | |
| 615 | 665 | if (strlen($value) > $length) { |
| 616 | 666 | $msg = $msg ?: "this field can be maximum $length charachter"; |
@@ -629,11 +679,15 @@ discard block |
||
| 629 | 679 | */ |
| 630 | 680 | public function minLen($length = null, $msg = null) |
| 631 | 681 | { |
| 632 | - if ($length === false) return $this; |
|
| 682 | + if ($length === false) { |
|
| 683 | + return $this; |
|
| 684 | + } |
|
| 633 | 685 | |
| 634 | 686 | $value = $this->value(); |
| 635 | 687 | |
| 636 | - if (!$value && $value != '0') return $this; |
|
| 688 | + if (!$value && $value != '0') { |
|
| 689 | + return $this; |
|
| 690 | + } |
|
| 637 | 691 | |
| 638 | 692 | if (strlen($value) < $length) { |
| 639 | 693 | $msg = $msg ?: "this field can be minimum $length charachter"; |
@@ -652,7 +706,9 @@ discard block |
||
| 652 | 706 | */ |
| 653 | 707 | public function match($input, $msg = null) |
| 654 | 708 | { |
| 655 | - if ($input === false) return $this; |
|
| 709 | + if ($input === false) { |
|
| 710 | + return $this; |
|
| 711 | + } |
|
| 656 | 712 | |
| 657 | 713 | $value = $this->value(); |
| 658 | 714 | |
@@ -677,11 +733,15 @@ discard block |
||
| 677 | 733 | */ |
| 678 | 734 | public function unique($data = [], $msg = null) |
| 679 | 735 | { |
| 680 | - if ($data === false) return $this; |
|
| 736 | + if ($data === false) { |
|
| 737 | + return $this; |
|
| 738 | + } |
|
| 681 | 739 | |
| 682 | 740 | $value = $this->value(); |
| 683 | 741 | |
| 684 | - if (!$data) return $this; |
|
| 742 | + if (!$data) { |
|
| 743 | + return $this; |
|
| 744 | + } |
|
| 685 | 745 | |
| 686 | 746 | if (is_array($data)) { |
| 687 | 747 | list($table, $column) = $data; |
@@ -739,7 +799,9 @@ discard block |
||
| 739 | 799 | */ |
| 740 | 800 | public function addError($input, $msg) |
| 741 | 801 | { |
| 742 | - if (!$this->hasError($input)) $this->errors[$input] = $msg; |
|
| 802 | + if (!$this->hasError($input)) { |
|
| 803 | + $this->errors[$input] = $msg; |
|
| 804 | + } |
|
| 743 | 805 | } |
| 744 | 806 | |
| 745 | 807 | /** |
@@ -440,7 +440,7 @@ |
||
| 440 | 440 | $splitChars = str_split($splitChars); |
| 441 | 441 | $splitChars = "\\" . implode('|\\', $splitChars); |
| 442 | 442 | } |
| 443 | - $re4 = "/.+(${splitChars})(.+|\\s)/"; |
|
| 443 | + $re4 = "/.+(${splitchars})(.+|\\s)/"; |
|
| 444 | 444 | if (preg_match_all($re4, $value)) { |
| 445 | 445 | $msg = $msg ?: 'charachters cant be between'; |
| 446 | 446 | |
@@ -117,7 +117,7 @@ |
||
| 117 | 117 | $this->container[$key] = $value; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - /** |
|
| 120 | + /** |
|
| 121 | 121 | * Get shared value |
| 122 | 122 | * |
| 123 | 123 | * @param string $key |
@@ -34,7 +34,9 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $this->share('file', $file); |
| 36 | 36 | |
| 37 | - if ($this->file->call('config/error.php')) $this->handleErrors(); |
|
| 37 | + if ($this->file->call('config/error.php')) { |
|
| 38 | + $this->handleErrors(); |
|
| 39 | + } |
|
| 38 | 40 | |
| 39 | 41 | $this->file->call('Core/helpers.php'); |
| 40 | 42 | } |
@@ -85,7 +87,9 @@ discard block |
||
| 85 | 87 | |
| 86 | 88 | $this->request->prepareUrl(); |
| 87 | 89 | |
| 88 | - foreach (glob("routes/**/*.php") as $route) $this->file->call($route); |
|
| 90 | + foreach (glob("routes/**/*.php") as $route) { |
|
| 91 | + $this->file->call($route); |
|
| 92 | + } |
|
| 89 | 93 | |
| 90 | 94 | $output = $this->route->getProperRoute(); |
| 91 | 95 | |
@@ -113,7 +117,9 @@ discard block |
||
| 113 | 117 | */ |
| 114 | 118 | public function share($key, $value) |
| 115 | 119 | { |
| 116 | - if ($value instanceof Closure) $value = call_user_func($value, $this); |
|
| 120 | + if ($value instanceof Closure) { |
|
| 121 | + $value = call_user_func($value, $this); |
|
| 122 | + } |
|
| 117 | 123 | $this->container[$key] = $value; |
| 118 | 124 | } |
| 119 | 125 | |
@@ -56,14 +56,18 @@ |
||
| 56 | 56 | |
| 57 | 57 | private function setAction($action) |
| 58 | 58 | { |
| 59 | - if ($this->basController) $action = $this->basController . '/' . $action; |
|
| 59 | + if ($this->basController) { |
|
| 60 | + $action = $this->basController . '/' . $action; |
|
| 61 | + } |
|
| 60 | 62 | |
| 61 | 63 | return $action; |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | 66 | private function setMiddleware($middleware) |
| 65 | 67 | { |
| 66 | - if (!is_array($middleware)) $middleware = [$middleware]; |
|
| 68 | + if (!is_array($middleware)) { |
|
| 69 | + $middleware = [$middleware]; |
|
| 70 | + } |
|
| 67 | 71 | $middleware = array_merge($this->groupMiddleware, $middleware); |
| 68 | 72 | return $middleware; |
| 69 | 73 | } |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | { |
| 93 | 93 | $args = func_get_args()[0]; |
| 94 | 94 | |
| 95 | - foreach($args as $join) { |
|
| 95 | + foreach ($args as $join) { |
|
| 96 | 96 | $sql[] = $join[0] . ' ON ' . $this->table . '.' . $join[1] . ' = ' . $join[0] . '.' . $join[2]; |
| 97 | 97 | } |
| 98 | 98 | $this->joins = $sql; |
@@ -42,7 +42,9 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | $this->app = $app; |
| 44 | 44 | |
| 45 | - if (!$this->isConnected()) $this->connect(); |
|
| 45 | + if (!$this->isConnected()) { |
|
| 46 | + $this->connect(); |
|
| 47 | + } |
|
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | private function isConnected() |
@@ -104,7 +106,9 @@ discard block |
||
| 104 | 106 | { |
| 105 | 107 | $sql = array_shift($bindings); |
| 106 | 108 | |
| 107 | - if (is_array($bindings[0])) $bindings = $bindings[0]; |
|
| 109 | + if (is_array($bindings[0])) { |
|
| 110 | + $bindings = $bindings[0]; |
|
| 111 | + } |
|
| 108 | 112 | |
| 109 | 113 | $this->addToBindings($bindings); |
| 110 | 114 | |
@@ -156,7 +160,9 @@ discard block |
||
| 156 | 160 | |
| 157 | 161 | public function fetch($table = null) |
| 158 | 162 | { |
| 159 | - if ($table) $this->table($table); |
|
| 163 | + if ($table) { |
|
| 164 | + $this->table($table); |
|
| 165 | + } |
|
| 160 | 166 | |
| 161 | 167 | $sql = $this->fetchStatment(); |
| 162 | 168 | |
@@ -173,7 +179,9 @@ discard block |
||
| 173 | 179 | |
| 174 | 180 | public function fetchAll($table = null) |
| 175 | 181 | { |
| 176 | - if ($table) $this->table($table); |
|
| 182 | + if ($table) { |
|
| 183 | + $this->table($table); |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | $sql = $this->fetchStatment(); |
| 179 | 187 | |
@@ -197,7 +205,9 @@ discard block |
||
| 197 | 205 | $sql .= ' FROM ' . $this->table . ' '; |
| 198 | 206 | |
| 199 | 207 | if (!empty($this->joins)) { |
| 200 | - foreach ($this->joins as $join) $sql .= 'LEFT JOIN ' . $join . ' '; |
|
| 208 | + foreach ($this->joins as $join) { |
|
| 209 | + $sql .= 'LEFT JOIN ' . $join . ' '; |
|
| 210 | + } |
|
| 201 | 211 | } |
| 202 | 212 | |
| 203 | 213 | if (!empty($this->wheres)) { |
@@ -258,7 +268,9 @@ discard block |
||
| 258 | 268 | |
| 259 | 269 | public function insert($table = null) |
| 260 | 270 | { |
| 261 | - if ($table) $this->table($table); |
|
| 271 | + if ($table) { |
|
| 272 | + $this->table($table); |
|
| 273 | + } |
|
| 262 | 274 | |
| 263 | 275 | $sql = 'INSERT INTO ' . $this->table . ' SET '; |
| 264 | 276 | |
@@ -273,13 +285,17 @@ discard block |
||
| 273 | 285 | |
| 274 | 286 | public function update($table = null) |
| 275 | 287 | { |
| 276 | - if ($table) $this->table($table); |
|
| 288 | + if ($table) { |
|
| 289 | + $this->table($table); |
|
| 290 | + } |
|
| 277 | 291 | |
| 278 | 292 | $sql = 'UPDATE ' . $this->table . ' SET '; |
| 279 | 293 | |
| 280 | 294 | $sql .= $this->setField(); |
| 281 | 295 | |
| 282 | - if (!empty($this->wheres)) $sql .= ' WHERE ' . implode('', $this->wheres); |
|
| 296 | + if (!empty($this->wheres)) { |
|
| 297 | + $sql .= ' WHERE ' . implode('', $this->wheres); |
|
| 298 | + } |
|
| 283 | 299 | |
| 284 | 300 | $this->query($sql, $this->bindings); |
| 285 | 301 | |
@@ -288,11 +304,15 @@ discard block |
||
| 288 | 304 | |
| 289 | 305 | public function delete($table = null) |
| 290 | 306 | { |
| 291 | - if ($table) $this->table($table); |
|
| 307 | + if ($table) { |
|
| 308 | + $this->table($table); |
|
| 309 | + } |
|
| 292 | 310 | |
| 293 | 311 | $sql = 'DELETE FROM ' . $this->table . ' '; |
| 294 | 312 | |
| 295 | - if (!empty($this->wheres)) $sql .= ' WHERE ' . implode('', $this->wheres); |
|
| 313 | + if (!empty($this->wheres)) { |
|
| 314 | + $sql .= ' WHERE ' . implode('', $this->wheres); |
|
| 315 | + } |
|
| 296 | 316 | |
| 297 | 317 | $this->query($sql, $this->bindings); |
| 298 | 318 | |
@@ -303,7 +323,9 @@ discard block |
||
| 303 | 323 | { |
| 304 | 324 | $sql = ''; |
| 305 | 325 | |
| 306 | - foreach ($this->data as $key => $value) $sql .= '`' . $key . '` = ? ,'; |
|
| 326 | + foreach ($this->data as $key => $value) { |
|
| 327 | + $sql .= '`' . $key . '` = ? ,'; |
|
| 328 | + } |
|
| 307 | 329 | |
| 308 | 330 | $sql = rtrim($sql, ' ,'); |
| 309 | 331 | |
@@ -323,7 +345,9 @@ discard block |
||
| 323 | 345 | { |
| 324 | 346 | $sql = array_shift($bindings); |
| 325 | 347 | |
| 326 | - if (count($bindings) == 1 and is_array($bindings[0])) $bindings = $bindings[0]; |
|
| 348 | + if (count($bindings) == 1 and is_array($bindings[0])) { |
|
| 349 | + $bindings = $bindings[0]; |
|
| 350 | + } |
|
| 327 | 351 | |
| 328 | 352 | try { |
| 329 | 353 | $query = $this->connection()->prepare($sql); |