Completed
Push — feature/fixing_cost ( 414fbf...99877f )
by Laurent
01:40
created

Guard   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRouteName() 0 4 1
A __invoke() 0 4 1
1
<?php
2
3
4
namespace FlightLog\Infrastructure\Common\Routes;
5
6
7
final class Guard
8
{
9
10
    /**
11
     * @var string
12
     */
13
    private $routeName;
14
15
    /**
16
     * @var callable
17
     */
18
    private $callable;
19
20
    /**
21
     * @param string $routeName
22
     * @param callable $callable
23
     */
24
    public function __construct($routeName, callable $callable)
25
    {
26
        $this->routeName = $routeName;
27
        $this->callable = $callable;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getRouteName()
34
    {
35
        return $this->routeName;
36
    }
37
38
    /**
39
     * @param \User $user
40
     * @return bool
41
     */
42
    public function __invoke(\User $user)
43
    {
44
        return call_user_func($this->callable, $user);
45
    }
46
}