@@ -5,14 +5,14 @@ discard block |
||
| 5 | 5 | use HnrAzevedo\Validator\Validator; |
| 6 | 6 | use Exception; |
| 7 | 7 | |
| 8 | -class Controller{ |
|
| 8 | +class Controller { |
|
| 9 | 9 | use Helper; |
| 10 | 10 | |
| 11 | 11 | protected array $fail = []; |
| 12 | 12 | |
| 13 | 13 | private function checkMethod(string $method): void |
| 14 | 14 | { |
| 15 | - if(!method_exists($this,$method)){ |
|
| 15 | + if (!method_exists($this, $method)) { |
|
| 16 | 16 | throw new Exception("{$method} not found in ".get_class($this)."."); |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $this->ValidateData(); |
| 23 | 23 | |
| 24 | - if($this->checkFailData()){ |
|
| 24 | + if ($this->checkFailData()) { |
|
| 25 | 25 | return false; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | $this->checkMethod($method); |
| 31 | 31 | |
| 32 | - call_user_func_array([$this,$method], func_get_args()); |
|
| 32 | + call_user_func_array([$this, $method], func_get_args()); |
|
| 33 | 33 | |
| 34 | 34 | return true; |
| 35 | 35 | } |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $valid = Validator::execute($this->getData()['POST']); |
| 40 | 40 | |
| 41 | - if(!$valid){ |
|
| 42 | - foreach(Validator::getErrors() as $err => $message){ |
|
| 41 | + if (!$valid) { |
|
| 42 | + foreach (Validator::getErrors() as $err => $message) { |
|
| 43 | 43 | $this->fail[] = [ |
| 44 | 44 | 'input' => array_keys($message)[0], |
| 45 | 45 | 'message' => $message[array_keys($message)[0]] |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | private function checkFailData(): bool |
| 52 | 52 | { |
| 53 | - if(count($this->fail) > 0 ){ |
|
| 53 | + if (count($this->fail) > 0) { |
|
| 54 | 54 | echo json_encode([ |
| 55 | 55 | 'error'=> $this->fail |
| 56 | 56 | ]); |
| 57 | 57 | } |
| 58 | - return (count($this->fail) > 0 ); |
|
| 58 | + return (count($this->fail) > 0); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | } |
| 62 | 62 | \ No newline at end of file |