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

Guard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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