Passed
Branch master (0aebca)
by Henri
02:15 queued 58s
created
src/FilterTrait.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Exception;
6 6
 
7
-trait FilterTrait{
7
+trait FilterTrait {
8 8
     protected function check_filtering(array $route)
9 9
     {
10
-        $filters = (is_array($route['filters'])) ? $route['filters'] : [ $route['filters'] ];
10
+        $filters = (is_array($route['filters'])) ? $route['filters'] : [$route['filters']];
11 11
 
12
-        foreach($filters as $filter){
13
-            if(is_null($filter)){
12
+        foreach ($filters as $filter) {
13
+            if (is_null($filter)) {
14 14
                 continue;
15 15
             }
16 16
             $this->check_filter($filter);
@@ -19,24 +19,24 @@  discard block
 block discarded – undo
19 19
 
20 20
     protected function check_filter(string $filtername)
21 21
     {
22
-        if(count(explode(':',$filtername)) != 2){
22
+        if (count(explode(':', $filtername)) != 2) {
23 23
             throw new Exception("Wrongly configured filter: {$filtername}.");
24 24
         }
25 25
 
26
-        $filter = $this->check_filClassExist(explode(':',$filtername)[0]);
26
+        $filter = $this->check_filClassExist(explode(':', $filtername)[0]);
27 27
 
28
-        if(!$filter->check(explode(':',$filtername)[1])){
29
-            throw new Exception($filter->getMessage(explode(':',$filtername)[1]));
28
+        if (!$filter->check(explode(':', $filtername)[1])) {
29
+            throw new Exception($filter->getMessage(explode(':', $filtername)[1]));
30 30
         }
31 31
     }
32 32
 
33 33
     protected function check_filClassExist(string $class)
34 34
     {
35
-        if(class_exists("HnrAzevedo\\Filter\\{$class}")){
35
+        if (class_exists("HnrAzevedo\\Filter\\{$class}")) {
36 36
             $filter = "HnrAzevedo\\Filter\\{$class}";
37 37
             return new $filter();
38 38
         }
39
-        if(file_exists(ROUTER_CONFIG['path.filters'].$class.'.php')){
39
+        if (file_exists(ROUTER_CONFIG['path.filters'].$class.'.php')) {
40 40
             require_once(ROUTER_CONFIG['path.filters'].$class.'.php');
41 41
             $filter = "HnrAzevedo\\Filter\\{$class}";
42 42
             return new $filter();
Please login to merge, or discard this patch.
examples/Filters/User.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 namespace HnrAzevedo\Filter;
4 4
 
5
-class User extends Filter{
5
+class User extends Filter {
6 6
 
7 7
     public function user_in(): bool
8 8
     {
9
-        $this->addMessage('user_in','User required to be logged in.');
9
+        $this->addMessage('user_in', 'User required to be logged in.');
10 10
 
11
-        $this->addTreat('user_in','report_notLogged');
11
+        $this->addTreat('user_in', 'report_notLogged');
12 12
 
13
-        return (array_key_exists('user',$_SESSION));
13
+        return (array_key_exists('user', $_SESSION));
14 14
     }
15 15
 
16 16
     public function report_notLogged(): void
Please login to merge, or discard this patch.