@@ -4,31 +4,31 @@ discard block |
||
4 | 4 | |
5 | 5 | use Exception; |
6 | 6 | |
7 | -trait CheckTrait{ |
|
7 | +trait CheckTrait { |
|
8 | 8 | use FilterTrait; |
9 | 9 | |
10 | 10 | protected function check_protocol(string $expected, string $current) |
11 | 11 | { |
12 | - if($expected !== $current){ |
|
13 | - throw new Exception('Page not found.',404); |
|
12 | + if ($expected !== $current) { |
|
13 | + throw new Exception('Page not found.', 404); |
|
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | - protected function check_name(string $route_name){ |
|
18 | - if(!array_key_exists($route_name,$this->routers)){ |
|
19 | - throw new Exception('Page not found.',404); |
|
17 | + protected function check_name(string $route_name) { |
|
18 | + if (!array_key_exists($route_name, $this->routers)) { |
|
19 | + throw new Exception('Page not found.', 404); |
|
20 | 20 | } |
21 | 21 | } |
22 | 22 | |
23 | - protected function check_typeRole($role){ |
|
24 | - if(!is_string($role) && @get_class($role) !== 'Closure' ){ |
|
23 | + protected function check_typeRole($role) { |
|
24 | + if (!is_string($role) && @get_class($role) !== 'Closure') { |
|
25 | 25 | throw new Exception("Improperly defined route track."); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | 29 | protected function check_config() |
30 | 30 | { |
31 | - if(!defined('ROUTER_CONFIG')){ |
|
31 | + if (!defined('ROUTER_CONFIG')) { |
|
32 | 32 | throw new Exception("Information for loading routes has not been defined."); |
33 | 33 | } |
34 | 34 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | protected function check_parameters(array $route_loop, array $route_request): bool |
42 | 42 | { |
43 | - foreach($route_loop as $rr => $param){ |
|
44 | - if( (substr($param,0,1) === '{') ){ |
|
45 | - $_GET[ substr($param,1,strlen($param)-2) ] = $route_request[$rr]; |
|
43 | + foreach ($route_loop as $rr => $param) { |
|
44 | + if ((substr($param, 0, 1) === '{')) { |
|
45 | + $_GET[substr($param, 1, strlen($param)-2)] = $route_request[$rr]; |
|
46 | 46 | } |
47 | 47 | |
48 | - if($this->check_parameter($param, $route_request[$rr])){ |
|
48 | + if ($this->check_parameter($param, $route_request[$rr])) { |
|
49 | 49 | return false; |
50 | 50 | } |
51 | 51 | } |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | |
55 | 55 | protected function check_parameter(string $route_loop, string $route_request) |
56 | 56 | { |
57 | - return !( substr($route_loop,0,1) === '{' ) and $route_loop !== $route_request; |
|
57 | + return !(substr($route_loop, 0, 1) === '{') and $route_loop !== $route_request; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | protected function check_role() |
61 | 61 | { |
62 | - if(!array_key_exists('role', $this->getData()['POST'])){ |
|
62 | + if (!array_key_exists('role', $this->getData()['POST'])) { |
|
63 | 63 | throw new Exception('O servidor não conseguiu identificar a finalidade deste formulário.'); |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | 67 | protected function hasProtocol(array $route, string $currentProtocol): bool |
68 | 68 | { |
69 | - $protocols = ( is_array($route['protocol']) ) ? $route['protocol'] : [ $route['protocol'] ]; |
|
69 | + $protocols = (is_array($route['protocol'])) ? $route['protocol'] : [$route['protocol']]; |
|
70 | 70 | $protocolEquals = false; |
71 | - foreach($protocols as $protocol){ |
|
72 | - if($protocol === $currentProtocol){ |
|
71 | + foreach ($protocols as $protocol) { |
|
72 | + if ($protocol === $currentProtocol) { |
|
73 | 73 | $protocolEquals = true; |
74 | 74 | } |
75 | 75 | } |