@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $path = realpath($path) ?: $path; |
131 | 131 | $tempPath = tempnam(dirname($path), basename($path)); |
132 | 132 | // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600... |
133 | - chmod($tempPath, 0777 - umask()); |
|
133 | + chmod($tempPath, 0777-umask()); |
|
134 | 134 | file_put_contents($tempPath, $content); |
135 | 135 | rename($tempPath, $path); |
136 | 136 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $success = true; |
190 | 190 | foreach ($paths as $path) { |
191 | 191 | try { |
192 | - if (! @unlink($path)) { |
|
192 | + if (!@unlink($path)) { |
|
193 | 193 | $success = false; |
194 | 194 | } |
195 | 195 | } catch (ErrorException $e) { |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function link($target, $link) |
234 | 234 | { |
235 | - if (! windows_os()) { |
|
235 | + if (!windows_os()) { |
|
236 | 236 | return symlink($target, $link); |
237 | 237 | } |
238 | 238 | $mode = $this->isDirectory($target) ? 'J' : 'H'; |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | public function files($directory, $hidden = false) |
394 | 394 | { |
395 | 395 | return iterator_to_array( |
396 | - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->depth(0)->sortByName(), |
|
396 | + Finder::create()->files()->ignoreDotFiles(!$hidden)->in($directory)->depth(0)->sortByName(), |
|
397 | 397 | false |
398 | 398 | ); |
399 | 399 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | public function allFiles($directory, $hidden = false) |
409 | 409 | { |
410 | 410 | return iterator_to_array( |
411 | - Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory)->sortByName(), |
|
411 | + Finder::create()->files()->ignoreDotFiles(!$hidden)->in($directory)->sortByName(), |
|
412 | 412 | false |
413 | 413 | ); |
414 | 414 | } |
@@ -455,10 +455,10 @@ discard block |
||
455 | 455 | */ |
456 | 456 | public function moveDirectory($from, $to, $overwrite = false) |
457 | 457 | { |
458 | - if ($overwrite && $this->isDirectory($to) && ! $this->deleteDirectory($to)) { |
|
458 | + if ($overwrite && $this->isDirectory($to) && !$this->deleteDirectory($to)) { |
|
459 | 459 | return false; |
460 | 460 | } |
461 | - return @rename($from, $to) === true; |
|
461 | + return @rename($from, $to)===true; |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | */ |
472 | 472 | public function copyDirectory($directory, $destination, $options = null) |
473 | 473 | { |
474 | - if (! $this->isDirectory($directory)) { |
|
474 | + if (!$this->isDirectory($directory)) { |
|
475 | 475 | return false; |
476 | 476 | } |
477 | 477 | $options = $options ?: FilesystemIterator::SKIP_DOTS; |
478 | 478 | // If the destination directory does not actually exist, we will go ahead and |
479 | 479 | // create it recursively, which just gets the destination prepared to copy |
480 | 480 | // the files over. Once we make the directory we'll proceed the copying. |
481 | - if (! $this->isDirectory($destination)) { |
|
481 | + if (!$this->isDirectory($destination)) { |
|
482 | 482 | $this->makeDirectory($destination, 0777, true); |
483 | 483 | } |
484 | 484 | $items = new FilesystemIterator($directory, $options); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | $target = $destination.'/'.$item->getBasename(); |
490 | 490 | if ($item->isDir()) { |
491 | 491 | $path = $item->getPathname(); |
492 | - if (! $this->copyDirectory($path, $target, $options)) { |
|
492 | + if (!$this->copyDirectory($path, $target, $options)) { |
|
493 | 493 | return false; |
494 | 494 | } |
495 | 495 | } |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | // location and keep looping. If for some reason the copy fails we'll bail out |
498 | 498 | // and return false, so the developer is aware that the copy process failed. |
499 | 499 | else { |
500 | - if (! $this->copy($item->getPathname(), $target)) { |
|
500 | + if (!$this->copy($item->getPathname(), $target)) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | } |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | */ |
517 | 517 | public function deleteDirectory($directory, $preserve = false) |
518 | 518 | { |
519 | - if (! $this->isDirectory($directory)) { |
|
519 | + if (!$this->isDirectory($directory)) { |
|
520 | 520 | return false; |
521 | 521 | } |
522 | 522 | $items = new FilesystemIterator($directory); |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | // If the item is a directory, we can just recurse into the function and |
525 | 525 | // delete that sub-directory otherwise we'll just delete the file and |
526 | 526 | // keep iterating through each file until the directory is cleaned. |
527 | - if ($item->isDir() && ! $item->isLink()) { |
|
527 | + if ($item->isDir() && !$item->isLink()) { |
|
528 | 528 | $this->deleteDirectory($item->getPathname()); |
529 | 529 | } |
530 | 530 | // If the item is just a file, we can go ahead and delete it since we're |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $this->delete($item->getPathname()); |
535 | 535 | } |
536 | 536 | } |
537 | - if (! $preserve) { |
|
537 | + if (!$preserve) { |
|
538 | 538 | @rmdir($directory); |
539 | 539 | } |
540 | 540 | return true; |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | public function deleteDirectories($directory) |
550 | 550 | { |
551 | 551 | $allDirectories = $this->directories($directory); |
552 | - if (! empty($allDirectories)) { |
|
552 | + if (!empty($allDirectories)) { |
|
553 | 553 | foreach ($allDirectories as $directoryName) { |
554 | 554 | $this->deleteDirectory($directoryName); |
555 | 555 | } |
@@ -580,17 +580,17 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function getAllFilesInDirectory($dir, $recursive = true, $basedir = '', $include_dirs = false) |
582 | 582 | { |
583 | - if ($dir == '') {return array();} else {$results = array(); $subresults = array();} |
|
584 | - if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent |
|
585 | - if ($basedir == '') {$basedir = realpath($dir).DIRECTORY_SEPARATOR;} |
|
583 | + if ($dir=='') {return array(); } else {$results = array(); $subresults = array(); } |
|
584 | + if (!is_dir($dir)) {$dir = dirname($dir); } // so a files path can be sent |
|
585 | + if ($basedir=='') {$basedir = realpath($dir).DIRECTORY_SEPARATOR; } |
|
586 | 586 | |
587 | 587 | $files = scandir($dir); |
588 | - foreach ($files as $key => $value){ |
|
589 | - if ( ($value != '.') && ($value != '..') ) { |
|
588 | + foreach ($files as $key => $value) { |
|
589 | + if (($value!='.') && ($value!='..')) { |
|
590 | 590 | $path = realpath($dir.DIRECTORY_SEPARATOR.$value); |
591 | 591 | if (is_dir($path)) { |
592 | 592 | // optionally include directories in file list |
593 | - if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path);} |
|
593 | + if ($include_dirs) {$subresults[] = str_replace($basedir, '', $path); } |
|
594 | 594 | // optionally get file list for all subdirectories |
595 | 595 | if ($recursive) { |
596 | 596 | $subdirresults = $this->getAllFilesInDirectory($path, $recursive, $basedir, $include_dirs); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | } |
604 | 604 | } |
605 | 605 | // merge the subarray to give the list of files then subdirectory files |
606 | - if (count($subresults) > 0) {$results = array_merge($subresults, $results);} |
|
606 | + if (count($subresults)>0) {$results = array_merge($subresults, $results); } |
|
607 | 607 | return $results; |
608 | 608 | } |
609 | 609 | |
@@ -625,15 +625,15 @@ discard block |
||
625 | 625 | * @param $param |
626 | 626 | * @return bool |
627 | 627 | */ |
628 | - public function change($executionPath,$param) |
|
628 | + public function change($executionPath, $param) |
|
629 | 629 | { |
630 | 630 | $dt = fopen($executionPath, "r"); |
631 | 631 | $content = fread($dt, filesize($executionPath)); |
632 | 632 | fclose($dt); |
633 | 633 | |
634 | - foreach ($param as $key=>$value){ |
|
634 | + foreach ($param as $key=>$value) { |
|
635 | 635 | |
636 | - $content=str_replace("".$key."",$value,$content); |
|
636 | + $content = str_replace("".$key."", $value, $content); |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | $dt = fopen($executionPath, "w"); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public function handle() |
24 | 24 | { |
25 | - foreach ($this->tableFilters() as $table=>$files){ |
|
25 | + foreach ($this->tableFilters() as $table=>$files) { |
|
26 | 26 | |
27 | 27 | $table = strtolower($table); |
28 | 28 | |
@@ -30,20 +30,20 @@ discard block |
||
30 | 30 | |
31 | 31 | $checkMigrationMain = $this->schema->getConnection()->checkMigrationMain(); |
32 | 32 | |
33 | - if($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])){ |
|
34 | - $this->apply($this->tableFilters()['Migrations'][0],'migrations'); |
|
33 | + if ($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])) { |
|
34 | + $this->apply($this->tableFilters()['Migrations'][0], 'migrations'); |
|
35 | 35 | } |
36 | 36 | |
37 | - $checkMigration = $this->schema->getConnection()->checkMigration($table,$file); |
|
37 | + $checkMigration = $this->schema->getConnection()->checkMigration($table, $file); |
|
38 | 38 | |
39 | - if(!$checkMigration){ |
|
39 | + if (!$checkMigration) { |
|
40 | 40 | |
41 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
41 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
42 | 42 | $className = $this->getClassName($getClassName); |
43 | 43 | |
44 | 44 | require_once ($file); |
45 | 45 | |
46 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
46 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
47 | 47 | |
48 | 48 | $this->list[$table][] = (new $className)->up($capsule); |
49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - app()->register('arguments','connection',$this->schema->getConnection()); |
|
54 | + app()->register('arguments', 'connection', $this->schema->getConnection()); |
|
55 | 55 | return $this->processHandler(); |
56 | 56 | } |
57 | 57 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * @param $table |
61 | 61 | * @return mixed|string |
62 | 62 | */ |
63 | - public function apply($file,$table) |
|
63 | + public function apply($file, $table) |
|
64 | 64 | { |
65 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
65 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
66 | 66 | $className = $this->getClassName($getClassName); |
67 | 67 | |
68 | 68 | require_once ($file); |
69 | 69 | |
70 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
70 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
71 | 71 | |
72 | 72 | $this->list[$table][] = (new $className)->up($capsule); |
73 | 73 |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param null $default |
21 | 21 | * @return mixed |
22 | 22 | */ |
23 | - public function input($key, $default=null); |
|
23 | + public function input($key, $default = null); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @param $key |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param $value |
46 | 46 | * @return void |
47 | 47 | */ |
48 | - public function set($key,$value); |
|
48 | + public function set($key, $value); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @return mixed |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param ApplicationContracts $app |
26 | 26 | * @param $request |
27 | 27 | */ |
28 | - public function __construct(ApplicationContracts $app,$request) |
|
28 | + public function __construct(ApplicationContracts $app, $request) |
|
29 | 29 | { |
30 | 30 | parent::__construct($app); |
31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param $key |
42 | 42 | * @return mixed|void |
43 | 43 | */ |
44 | - public function annotation($method,$key) |
|
44 | + public function annotation($method, $key) |
|
45 | 45 | { |
46 | 46 | //set annotation value with getting reflection |
47 | 47 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method); |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | * @param string $key |
67 | 67 | * @param null|string $data |
68 | 68 | */ |
69 | - private function catchException($key,$data) |
|
69 | + private function catchException($key, $data) |
|
70 | 70 | { |
71 | - if(isset($this->exceptionParams[$key])){ |
|
71 | + if (isset($this->exceptionParams[$key])) { |
|
72 | 72 | |
73 | 73 | //get key params for exception params |
74 | 74 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
75 | 75 | |
76 | 76 | //catch exception |
77 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
77 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
78 | 78 | ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')'); |
79 | 79 | } |
80 | - else{ |
|
80 | + else { |
|
81 | 81 | //catch exception |
82 | 82 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
83 | 83 | } |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private function getException($key) |
92 | 92 | { |
93 | - if(preg_match('@exception\((.*?)\)|exception\((.*?)\)\r\n@is',$this->annotation,$exception)){ |
|
93 | + if (preg_match('@exception\((.*?)\)|exception\((.*?)\)\r\n@is', $this->annotation, $exception)) { |
|
94 | 94 | |
95 | - $exceptionSpaceExplode = explode(" ",$exception[1]); |
|
95 | + $exceptionSpaceExplode = explode(" ", $exception[1]); |
|
96 | 96 | |
97 | - foreach ($exceptionSpaceExplode as $exceptions){ |
|
98 | - $exceptionsDotExplode = explode(":",$exceptions); |
|
97 | + foreach ($exceptionSpaceExplode as $exceptions) { |
|
98 | + $exceptionsDotExplode = explode(":", $exceptions); |
|
99 | 99 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
100 | 100 | } |
101 | 101 | |
102 | - if(isset($this->exceptionParams[$key]['params'])){ |
|
102 | + if (isset($this->exceptionParams[$key]['params'])) { |
|
103 | 103 | |
104 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']); |
|
104 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']); |
|
105 | 105 | unset($this->exceptionParams[$key]['params']); |
106 | 106 | |
107 | - foreach ($paramsCommaExplode as $params){ |
|
108 | - $paramsEqualExplode = explode("=",$params); |
|
109 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){ |
|
107 | + foreach ($paramsCommaExplode as $params) { |
|
108 | + $paramsEqualExplode = explode("=", $params); |
|
109 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) { |
|
110 | 110 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
111 | 111 | } |
112 | 112 | } |
@@ -123,37 +123,37 @@ discard block |
||
123 | 123 | { |
124 | 124 | // with the method based regex annotation, |
125 | 125 | // we check the rule definition for our requests. |
126 | - if(preg_match('@regex\((.*?)\)|regex\((.*?)\)\r\n@is',$this->annotation,$regex)){ |
|
127 | - if(isset($this->inputs[$key])){ |
|
126 | + if (preg_match('@regex\((.*?)\)|regex\((.*?)\)\r\n@is', $this->annotation, $regex)) { |
|
127 | + if (isset($this->inputs[$key])) { |
|
128 | 128 | |
129 | 129 | // for the definition of rules, |
130 | 130 | // our inputs can be array and in this case we offer array option for user comfort. |
131 | - if(is_array($this->inputs[$key])){ |
|
131 | + if (is_array($this->inputs[$key])) { |
|
132 | 132 | |
133 | - foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){ |
|
133 | + foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) { |
|
134 | 134 | |
135 | - if(is_array($this->inputsValue)){ |
|
135 | + if (is_array($this->inputsValue)) { |
|
136 | 136 | |
137 | - foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem){ |
|
138 | - if(!preg_match('@'.$regex[1].'@is',$inputsValueItem)){ |
|
139 | - $this->catchException($key,$regex[1]); |
|
137 | + foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem) { |
|
138 | + if (!preg_match('@'.$regex[1].'@is', $inputsValueItem)) { |
|
139 | + $this->catchException($key, $regex[1]); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | - else{ |
|
145 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){ |
|
146 | - $this->catchException($key,$regex[1]); |
|
144 | + else { |
|
145 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) { |
|
146 | + $this->catchException($key, $regex[1]); |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
151 | 151 | } |
152 | - else{ |
|
152 | + else { |
|
153 | 153 | |
154 | 154 | // we control the regex rule that evaluates when only string arrives. |
155 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){ |
|
156 | - $this->catchException($key,$regex[1]); |
|
155 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) { |
|
156 | + $this->catchException($key, $regex[1]); |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
@@ -168,9 +168,9 @@ discard block |
||
168 | 168 | */ |
169 | 169 | private function getRemove($key) |
170 | 170 | { |
171 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){ |
|
172 | - if(isset($this->inputs[$key])){ |
|
173 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){ |
|
171 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) { |
|
172 | + if (isset($this->inputs[$key])) { |
|
173 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) { |
|
174 | 174 | unset($this->inputs[$key]); |
175 | 175 | } |
176 | 176 | } |
@@ -184,33 +184,33 @@ discard block |
||
184 | 184 | */ |
185 | 185 | private function getRules($key) |
186 | 186 | { |
187 | - if(preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is',$this->annotation,$rule)){ |
|
187 | + if (preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is', $this->annotation, $rule)) { |
|
188 | 188 | |
189 | 189 | $requestRules = $this->getReflection('rules'); |
190 | 190 | |
191 | - $rules = explode(":",$rule[1]); |
|
192 | - if(isset($this->inputs[$key]) && !is_array($this->inputs[$key])){ |
|
193 | - foreach($rules as $rule){ |
|
191 | + $rules = explode(":", $rule[1]); |
|
192 | + if (isset($this->inputs[$key]) && !is_array($this->inputs[$key])) { |
|
193 | + foreach ($rules as $rule) { |
|
194 | 194 | |
195 | - $ruleExplode = explode('#',$rule); |
|
195 | + $ruleExplode = explode('#', $rule); |
|
196 | 196 | $rule = $ruleExplode[0]; |
197 | 197 | |
198 | - if(isset($requestRules[$rule])){ |
|
199 | - if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){ |
|
200 | - exception($rule,['key'=>$key.':'.$this->inputs[$key]]) |
|
198 | + if (isset($requestRules[$rule])) { |
|
199 | + if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) { |
|
200 | + exception($rule, ['key'=>$key.':'.$this->inputs[$key]]) |
|
201 | 201 | ->invalidArgument($key.':'.$this->inputs[$key].' input value is not valid for '.$rule.' request rule'); |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | 205 | //rule method |
206 | - if(!isset($requestRules[$rule])){ |
|
207 | - $this->request->call(function() use($rule,$key,$ruleExplode){ |
|
208 | - if(method_exists($this,$ruleMethod = '__rule'.ucfirst($rule))){ |
|
209 | - if(isset($ruleExplode[1])){ |
|
206 | + if (!isset($requestRules[$rule])) { |
|
207 | + $this->request->call(function() use($rule, $key, $ruleExplode){ |
|
208 | + if (method_exists($this, $ruleMethod = '__rule'.ucfirst($rule))) { |
|
209 | + if (isset($ruleExplode[1])) { |
|
210 | 210 | |
211 | 211 | $reValueList = []; |
212 | - foreach (explode(',',$ruleExplode[1]) as $reValue){ |
|
213 | - $reValueExplode = explode('=',$reValue); |
|
212 | + foreach (explode(',', $ruleExplode[1]) as $reValue) { |
|
213 | + $reValueExplode = explode('=', $reValue); |
|
214 | 214 | $reValueListKey = $reValueExplode[0]; |
215 | 215 | $reValueListValue = (isset($reValueExplode[1])) ? $reValueExplode[1] : null; |
216 | 216 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | |
219 | 219 | } |
220 | 220 | |
221 | - $this->{$ruleMethod}($key,$this->inputs[$key],$reValueList); |
|
221 | + $this->{$ruleMethod}($key, $this->inputs[$key], $reValueList); |
|
222 | 222 | } |
223 | - else{ |
|
224 | - $this->{$ruleMethod}($key,$this->inputs[$key]); |
|
223 | + else { |
|
224 | + $this->{$ruleMethod}($key, $this->inputs[$key]); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | } |
@@ -229,27 +229,27 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | } |
232 | - else{ |
|
232 | + else { |
|
233 | 233 | |
234 | - foreach ($this->inputs[$key] as $ikey=>$input){ |
|
234 | + foreach ($this->inputs[$key] as $ikey=>$input) { |
|
235 | 235 | |
236 | - if(!is_array($input)){ |
|
237 | - foreach($rules as $rule){ |
|
238 | - if(isset($requestRules[$rule])){ |
|
239 | - if(!preg_match('@'.$requestRules[$rule].'@',$input)){ |
|
240 | - exception($rule,['key'=>''.$key.':'.$input]) |
|
236 | + if (!is_array($input)) { |
|
237 | + foreach ($rules as $rule) { |
|
238 | + if (isset($requestRules[$rule])) { |
|
239 | + if (!preg_match('@'.$requestRules[$rule].'@', $input)) { |
|
240 | + exception($rule, ['key'=>''.$key.':'.$input]) |
|
241 | 241 | ->invalidArgument($key.':'.$input.' input value is not valid for '.$rule.' request rule'); |
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | } |
246 | - else{ |
|
246 | + else { |
|
247 | 247 | |
248 | - foreach ($input as $ikey=>$item){ |
|
249 | - foreach($rules as $rule){ |
|
250 | - if(isset($requestRules[$rule])){ |
|
251 | - if(!preg_match('@'.$requestRules[$rule].'@',$item)){ |
|
252 | - exception($rule,['key'=>''.$key.':'.$item]) |
|
248 | + foreach ($input as $ikey=>$item) { |
|
249 | + foreach ($rules as $rule) { |
|
250 | + if (isset($requestRules[$rule])) { |
|
251 | + if (!preg_match('@'.$requestRules[$rule].'@', $item)) { |
|
252 | + exception($rule, ['key'=>''.$key.':'.$item]) |
|
253 | 253 | ->invalidArgument($key.':'.$item.' input value is not valid for '.$rule.' request rule'); |
254 | 254 | } |
255 | 255 | } |
@@ -76,8 +76,7 @@ discard block |
||
76 | 76 | //catch exception |
77 | 77 | exception($this->exceptionParams[$key]['name'],$keyParams) |
78 | 78 | ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')'); |
79 | - } |
|
80 | - else{ |
|
79 | + } else{ |
|
81 | 80 | //catch exception |
82 | 81 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')'); |
83 | 82 | } |
@@ -140,16 +139,14 @@ discard block |
||
140 | 139 | } |
141 | 140 | } |
142 | 141 | |
143 | - } |
|
144 | - else{ |
|
142 | + } else{ |
|
145 | 143 | if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){ |
146 | 144 | $this->catchException($key,$regex[1]); |
147 | 145 | } |
148 | 146 | } |
149 | 147 | |
150 | 148 | } |
151 | - } |
|
152 | - else{ |
|
149 | + } else{ |
|
153 | 150 | |
154 | 151 | // we control the regex rule that evaluates when only string arrives. |
155 | 152 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){ |
@@ -219,8 +216,7 @@ discard block |
||
219 | 216 | } |
220 | 217 | |
221 | 218 | $this->{$ruleMethod}($key,$this->inputs[$key],$reValueList); |
222 | - } |
|
223 | - else{ |
|
219 | + } else{ |
|
224 | 220 | $this->{$ruleMethod}($key,$this->inputs[$key]); |
225 | 221 | } |
226 | 222 | |
@@ -228,8 +224,7 @@ discard block |
||
228 | 224 | }); |
229 | 225 | } |
230 | 226 | } |
231 | - } |
|
232 | - else{ |
|
227 | + } else{ |
|
233 | 228 | |
234 | 229 | foreach ($this->inputs[$key] as $ikey=>$input){ |
235 | 230 | |
@@ -242,8 +237,7 @@ discard block |
||
242 | 237 | } |
243 | 238 | } |
244 | 239 | } |
245 | - } |
|
246 | - else{ |
|
240 | + } else{ |
|
247 | 241 | |
248 | 242 | foreach ($input as $ikey=>$item){ |
249 | 243 | foreach($rules as $rule){ |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | private function dataIncludedForPrinter($printer) |
20 | 20 | { |
21 | - if(isset(core()->controllerWatch)){ |
|
21 | + if (isset(core()->controllerWatch)) { |
|
22 | 22 | |
23 | 23 | $watch = core()->controllerWatch; |
24 | - return array_merge($printer,['watch'=>['memory'=>$watch['memory']]]); |
|
24 | + return array_merge($printer, ['watch'=>['memory'=>$watch['memory']]]); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | //return printer |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | * @param array $data |
49 | 49 | * @return array |
50 | 50 | */ |
51 | - private function hateoasCapsule($data=array()) |
|
51 | + private function hateoasCapsule($data = array()) |
|
52 | 52 | { |
53 | - return (config('app.hateoas')) ? array_merge($data,config('hateoas')) : $data; |
|
53 | + return (config('app.hateoas')) ? array_merge($data, config('hateoas')) : $data; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @param callable $callback |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - private function noInExceptionHateoas($output,callable $callback) |
|
69 | + private function noInExceptionHateoas($output, callable $callback) |
|
70 | 70 | { |
71 | - if(isset($output['success']) && false===$output['success']){ |
|
71 | + if (isset($output['success']) && false===$output['success']) { |
|
72 | 72 | return $output; |
73 | 73 | } |
74 | 74 | return call_user_func($callback); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | //if the system throws an exception, |
97 | 97 | //we subtract the hateoas extension from the output value. |
98 | - $this->printer = $this->noInExceptionHateoas($output,function() use ($output){ |
|
98 | + $this->printer = $this->noInExceptionHateoas($output, function() use ($output){ |
|
99 | 99 | |
100 | 100 | return array_merge( |
101 | 101 | $this->metaAdd(), |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | |
110 | 110 | // If the log feature is available on the kernel, |
111 | 111 | // we run the logger process. |
112 | - if(isset(core()->log)){ |
|
112 | + if (isset(core()->log)) { |
|
113 | 113 | |
114 | 114 | // we can run logging after checking |
115 | 115 | // the configuration for the logger process in the LoggerService class |
116 | 116 | // so that,If logging is not allowed in the main configuration file, we will not log. |
117 | - return core()->loggerService->checkLoggerConfiguration($this->printer,function($printer){ |
|
117 | + return core()->loggerService->checkLoggerConfiguration($this->printer, function($printer) { |
|
118 | 118 | return $printer; |
119 | 119 | }); |
120 | 120 | } |
@@ -57,8 +57,7 @@ |
||
57 | 57 | |
58 | 58 | if(is_array($event = $this->fireEvent('output',true))){ |
59 | 59 | $controller = $event; |
60 | - } |
|
61 | - else{ |
|
60 | + } else{ |
|
62 | 61 | |
63 | 62 | //the singleton eager class is a class built to temporarily prevent |
64 | 63 | //the use of user-side kernel objects used by the rest system. |
@@ -20,19 +20,19 @@ discard block |
||
20 | 20 | * @param bool $return |
21 | 21 | * @return mixed|void |
22 | 22 | */ |
23 | - private function fireEvent($event=null,$return=false) |
|
23 | + private function fireEvent($event = null, $return = false) |
|
24 | 24 | { |
25 | 25 | // if an array of response-events is registered |
26 | 26 | // in the container system, the event will fire. |
27 | - if($this->app->has('response-event.'.$event)){ |
|
27 | + if ($this->app->has('response-event.'.$event)) { |
|
28 | 28 | $event = $this->app->get('response-event.'.$event); |
29 | 29 | |
30 | 30 | // the event to be fired must be |
31 | 31 | // a closure instance. |
32 | - if($event instanceof Closure){ |
|
32 | + if ($event instanceof Closure) { |
|
33 | 33 | $eventResolved = $event($this->app); |
34 | 34 | |
35 | - if($return){ |
|
35 | + if ($return) { |
|
36 | 36 | return $eventResolved; |
37 | 37 | } |
38 | 38 | } |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private function callController() |
51 | 51 | { |
52 | - $this->fireEvent('before',true); |
|
52 | + $this->fireEvent('before', true); |
|
53 | 53 | |
54 | - if($this->app->has('output')){ |
|
54 | + if ($this->app->has('output')) { |
|
55 | 55 | return $this->app->get('output'); |
56 | 56 | } |
57 | 57 | |
58 | - if(is_array($event = $this->fireEvent('output',true))){ |
|
58 | + if (is_array($event = $this->fireEvent('output', true))) { |
|
59 | 59 | $controller = $event; |
60 | 60 | } |
61 | - else{ |
|
61 | + else { |
|
62 | 62 | |
63 | 63 | //the singleton eager class is a class built to temporarily prevent |
64 | 64 | //the use of user-side kernel objects used by the rest system. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $controller = $this->getCallBindController(); |
70 | 70 | } |
71 | 71 | |
72 | - $this->app->register('output',$controller); |
|
72 | + $this->app->register('output', $controller); |
|
73 | 73 | |
74 | 74 | return $controller; |
75 | 75 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | private function getCallBindController() |
83 | 83 | { |
84 | 84 | //we finally process the method of the class invoked by the user as a process and prepare it for the response |
85 | - return app()->resolve(RouteWatch::class)->watch(function(){ |
|
85 | + return app()->resolve(RouteWatch::class)->watch(function() { |
|
86 | 86 | |
87 | 87 | // if the method in the instance object exists, |
88 | 88 | // this method is executed to produce the output. |
89 | - if(method_exists($this->app['instanceController'],$this->app['method'])){ |
|
90 | - return $this->app['di']($this->app['instanceController'],$this->app['method']); |
|
89 | + if (method_exists($this->app['instanceController'], $this->app['method'])) { |
|
90 | + return $this->app['di']($this->app['instanceController'], $this->app['method']); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | //throw exception as unsuccessful |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function handle() |
107 | 107 | { |
108 | - $this->app->register('routerResult',$this->callController()); |
|
108 | + $this->app->register('routerResult', $this->callController()); |
|
109 | 109 | |
110 | 110 | //we call our services as controller |
111 | 111 | return $this->app['routerResult']; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | $namespace = $this->getControllerNamespace(); |
123 | 123 | |
124 | 124 | //utils make bind via dependency injection named as service container |
125 | - $this->app->register('serviceConf',$this->app['fileSystem']->callFile(StaticPathModel::getServiceConf())); |
|
126 | - $this->app->register('instanceController',$this->app->resolve($namespace)); |
|
125 | + $this->app->register('serviceConf', $this->app['fileSystem']->callFile(StaticPathModel::getServiceConf())); |
|
126 | + $this->app->register('instanceController', $this->app->resolve($namespace)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | // based on the serviceConf variable, |
142 | 142 | // we are doing parameter bindings in the method context in the routeParameters array key. |
143 | - $this->app->register('serviceConf','routeParameters',[$method=>$parameters]); |
|
143 | + $this->app->register('serviceConf', 'routeParameters', [$method=>$parameters]); |
|
144 | 144 | |
145 | 145 | } |
146 | 146 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function setMethodNameViaDefine($methodName) |
154 | 154 | { |
155 | - define('methodName',strtolower($methodName)); |
|
155 | + define('methodName', strtolower($methodName)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $fromRoutes = Route::getRouteResolve(); |
184 | 184 | $method = $fromRoutes['method'] ?? $method; |
185 | 185 | |
186 | - $this->app->register('method',$method); |
|
186 | + $this->app->register('method', $method); |
|
187 | 187 | $this->app->register('routeParameters', $this->routeParametersAssign($this->resolveMethod($method))); |
188 | 188 | |
189 | 189 | } |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | //the auto service to be called. |
29 | 29 | return ClosureDispatcher::bind($controllerInstance)->call(function() use($controllerInstance){ |
30 | 30 | |
31 | - if(property_exists($controllerInstance,'response')){ |
|
31 | + if (property_exists($controllerInstance, 'response')) { |
|
32 | 32 | return $controllerInstance->response; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // if the client wishes, |
36 | 36 | // data can be returned in the supported format. |
37 | - if(app()->has('clientResponseType')){ |
|
37 | + if (app()->has('clientResponseType')) { |
|
38 | 38 | return app()->get('clientResponseType'); |
39 | 39 | } |
40 | 40 | |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | * @param bool $return |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - protected function fireEvent($event=null,$return=false) |
|
52 | + protected function fireEvent($event = null, $return = false) |
|
53 | 53 | { |
54 | 54 | // if an array of response-events is registered |
55 | 55 | // in the container system, the event will fire. |
56 | - if($this->app->has('response-event.'.$event)){ |
|
56 | + if ($this->app->has('response-event.'.$event)) { |
|
57 | 57 | $event = $this->app->get('response-event.'.$event); |
58 | 58 | |
59 | 59 | // the event to be fired must be |
60 | 60 | // a closure instance. |
61 | - if($event instanceof Closure){ |
|
61 | + if ($event instanceof Closure) { |
|
62 | 62 | $eventResolved = $event($this->app); |
63 | 63 | |
64 | - if($return){ |
|
64 | + if ($return) { |
|
65 | 65 | return $eventResolved; |
66 | 66 | } |
67 | 67 | } |
@@ -100,8 +100,7 @@ discard block |
||
100 | 100 | { |
101 | 101 | //we get the response type by checking the instanceController object from the router. |
102 | 102 | //Each type of response is in the base class in project directory. |
103 | - return ($this->getControllerInstance()===null) ? core()->responseType : |
|
104 | - $this->appResponseType(); |
|
103 | + return ($this->getControllerInstance()===null) ? core()->responseType : $this->appResponseType(); |
|
105 | 104 | } |
106 | 105 | |
107 | 106 | /** |
@@ -112,13 +111,13 @@ discard block |
||
112 | 111 | public function handle() |
113 | 112 | { |
114 | 113 | //definition for singleton instance |
115 | - define ('responseApp',true); |
|
114 | + define('responseApp', true); |
|
116 | 115 | |
117 | 116 | //get out putter for response |
118 | 117 | $formatter = $this->formatter(); |
119 | 118 | |
120 | 119 | //if out putter is not null |
121 | - if(Utils::isNamespaceExists($formatter)){ |
|
120 | + if (Utils::isNamespaceExists($formatter)) { |
|
122 | 121 | |
123 | 122 | //get outputter for result |
124 | 123 | $outPutter = $this->getOutPutter(); |
@@ -127,9 +126,9 @@ discard block |
||
127 | 126 | // and run the handle method. |
128 | 127 | $result = app()->resolve($formatter)->{$this->getResponseKind()}($outPutter); |
129 | 128 | |
130 | - $this->app->register('result',$result); |
|
129 | + $this->app->register('result', $result); |
|
131 | 130 | |
132 | - $this->fireEvent('after',true); |
|
131 | + $this->fireEvent('after', true); |
|
133 | 132 | } |
134 | 133 | } |
135 | 134 | |
@@ -139,7 +138,7 @@ discard block |
||
139 | 138 | * @param array $data |
140 | 139 | * @return array |
141 | 140 | */ |
142 | - public function outputFormatter($data=array(),$outputter='json') |
|
141 | + public function outputFormatter($data = array(), $outputter = 'json') |
|
143 | 142 | { |
144 | 143 | $dataCapsule = config('response.data'); |
145 | 144 |