@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -trait CheckTrait{ |
|
7 | +trait CheckTrait { |
|
8 | 8 | use FilterTrait, CheckWhere; |
9 | 9 | |
10 | 10 | protected function checkProtocol(string $expected, string $current): bool |
@@ -12,21 +12,21 @@ discard block |
||
12 | 12 | return ($expected === $current); |
13 | 13 | } |
14 | 14 | |
15 | - protected function checkName(string $routeName){ |
|
16 | - if(!array_key_exists($routeName,$this->routers)){ |
|
15 | + protected function checkName(string $routeName) { |
|
16 | + if (!array_key_exists($routeName, $this->routers)) { |
|
17 | 17 | throw new Exception('Page not found.', 404); |
18 | 18 | } |
19 | 19 | } |
20 | 20 | |
21 | - protected function checkTypeRole($role){ |
|
22 | - if(!is_string($role) && @get_class($role) !== 'Closure' ){ |
|
21 | + protected function checkTypeRole($role) { |
|
22 | + if (!is_string($role) && @get_class($role) !== 'Closure') { |
|
23 | 23 | throw new Exception("Improperly defined route track."); |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
27 | 27 | protected function checkConfig() |
28 | 28 | { |
29 | - if(!defined('ROUTER_CONFIG')){ |
|
29 | + if (!defined('ROUTER_CONFIG')) { |
|
30 | 30 | throw new Exception("Information for loading routes has not been defined."); |
31 | 31 | } |
32 | 32 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function checkParameters(array $routeLoop, array $routeRequest): bool |
40 | 40 | { |
41 | - foreach($routeLoop as $rr => $param){ |
|
42 | - if( (substr($param,0,1) === '{') ){ |
|
43 | - $_GET[ substr($param,1,strlen($param)-2) ] = $routeRequest[$rr]; |
|
41 | + foreach ($routeLoop as $rr => $param) { |
|
42 | + if ((substr($param, 0, 1) === '{')) { |
|
43 | + $_GET[substr($param, 1, strlen($param)-2)] = $routeRequest[$rr]; |
|
44 | 44 | } |
45 | 45 | |
46 | - if($this->checkParameter($param, $routeRequest[$rr])){ |
|
46 | + if ($this->checkParameter($param, $routeRequest[$rr])) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | } |
@@ -52,22 +52,22 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function checkParameter(string $routeLoop, string $routeRequest) |
54 | 54 | { |
55 | - return !( substr($routeLoop,0,1) === '{' ) and $routeLoop !== $routeRequest; |
|
55 | + return !(substr($routeLoop, 0, 1) === '{') and $routeLoop !== $routeRequest; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | protected function checkRole() |
59 | 59 | { |
60 | - if(!array_key_exists('role', $this->getData()['POST'])){ |
|
60 | + if (!array_key_exists('role', $this->getData()['POST'])) { |
|
61 | 61 | throw new Exception('O servidor não conseguiu identificar a finalidade deste formulário.'); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | protected function hasProtocol(array $route, string $currentProtocol) |
66 | 66 | { |
67 | - $protocols = ( is_array($route['protocol']) ) ? $route['protocol'] : [ $route['protocol'] ]; |
|
67 | + $protocols = (is_array($route['protocol'])) ? $route['protocol'] : [$route['protocol']]; |
|
68 | 68 | |
69 | - foreach($protocols as $protocol){ |
|
70 | - if($protocol !== $currentProtocol){ |
|
69 | + foreach ($protocols as $protocol) { |
|
70 | + if ($protocol !== $currentProtocol) { |
|
71 | 71 | continue; |
72 | 72 | } |
73 | 73 | } |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | protected function checkToHiking($route, $routeRequest, $routeLoop): bool |
77 | 77 | { |
78 | - if($this->checkNumparams($routeLoop, $routeRequest) || |
|
78 | + if ($this->checkNumparams($routeLoop, $routeRequest) || |
|
79 | 79 | $this->checkParameters($routeLoop, $routeRequest) || |
80 | - $this->checkWhere($route, $routeRequest)){ |
|
80 | + $this->checkWhere($route, $routeRequest)) { |
|
81 | 81 | return false; |
82 | 82 | } |
83 | 83 | return true; |