Passed
Push — master ( 3472d9...63f321 )
by Henri
01:18
created

CheckTrait   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check_name() 0 3 2
A check_filtering() 0 6 3
A check_protocol() 0 4 2
1
<?php
2
3
namespace HnrAzevedo\Router;
4
5
use Exception;
6
7
trait CheckTrait{
8
9
    protected function check_protocol(string $expected, string $current)
10
    {
11
        if($expected !== $current){
12
            throw new Exception('Page not found.',404);
13
        }
14
    }
15
16
    protected function check_name(string $route_name){
17
        if(!array_key_exists($route_name,$this->routers)){
18
            throw new Exception('Page not found.',404);
19
        }
20
    }
21
22
    protected function check_filtering(array $route)
23
    {
24
        $filters = (is_array($route['filters'])) ? $route['filters'] : [ $route['filters'] ];
25
26
        foreach($filters as $filter){
27
            $this->filter->filtering($filter);
28
        }
29
    }
30
31
}