Completed
Push — master ( 3528ad...ff9b79 )
by Alexpts
02:31
created

EndPoint   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 81.82%
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 43
ccs 9
cts 11
cp 0.8182
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 4 1
A setArgs() 0 5 1
A getArgs() 0 4 1
1
<?php
2
namespace PTS\Routing;
3
4
class EndPoint
5
{
6
    /** @var callable */
7
    protected $handler;
8
    /** @var array */
9
    protected $args = [];
10
11
    /**
12
     * @param callable $handler
13
     * @param array $args
14
     */
15 34
    public function __construct(callable $handler, array $args = [])
16
    {
17 34
        $this->handler = $handler;
18 34
        $this->args = $args;
19 34
    }
20
21
    /**
22
     * @return mixed
23
     */
24
    public function __invoke()
25
    {
26
        return call_user_func_array($this->handler, $this->args);
27
    }
28
29
    /**
30
     * @param array $args
31
     * @return $this
32
     */
33 7
    public function setArgs(array $args = [])
34
    {
35 7
        $this->args = $args;
36 7
        return $this;
37
    }
38
39
    /**
40
     * @return array
41
     */
42 6
    public function getArgs() : array
43
    {
44 6
        return $this->args;
45
    }
46
}
47