| Total Complexity | 9 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Controller{ |
||
| 9 | use Helper; |
||
|
|
|||
| 10 | |||
| 11 | protected array $fail = []; |
||
| 12 | |||
| 13 | private function check_method(string $method): void |
||
| 14 | { |
||
| 15 | if(!method_exists($this,$method)){ |
||
| 16 | throw new Exception("{$method} not found in ".get_class($this)."."); |
||
| 17 | } |
||
| 18 | } |
||
| 19 | |||
| 20 | public function method(): bool |
||
| 21 | { |
||
| 22 | $this->ValidateData(); |
||
| 23 | |||
| 24 | if($this->check_failData()){ |
||
| 25 | return false; |
||
| 26 | } |
||
| 27 | |||
| 28 | $method = $this->getData()['POST']['role']; |
||
| 29 | |||
| 30 | $this->check_method($method); |
||
| 31 | |||
| 32 | $this->$method(); |
||
| 33 | |||
| 34 | return true; |
||
| 35 | } |
||
| 36 | |||
| 37 | private function ValidateData(): void |
||
| 46 | ]; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | private function check_failData(): bool |
||
| 61 | } |