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

CheckTrait::check_protocol()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 4
rs 10
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
}