Route::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace PTS\PSR15Routing;
5
6
use Psr\Http\Server\RequestHandlerInterface;
7
8
class Route
9
{
10
    /** @var string */
11
    protected $path;
12
    /** @var RequestHandlerInterface */
13
    protected $handler;
14
    /** @var array */
15
    protected $matches = [];
16
    /** @var array */
17
    protected $methods = [];
18
    /** @var array */
19
    protected $restrictions = [];
20
21 22
    public function __construct(string $path, RequestHandlerInterface $handler)
22
    {
23 22
        $this->path = $path;
24 22
        $this->handler = $handler;
25 22
    }
26
27 4
    public function setMatches(array $values = []): self
28
    {
29 4
        $this->matches = $values;
30 4
        return $this;
31
    }
32
33 4
    public function getMatchesParams(): array
34
    {
35 4
        return $this->matches;
36
    }
37
38 13
    public function getMethods(): array
39
    {
40 13
        return $this->methods;
41
    }
42
43 9
    public function setMethods(array $methods): self
44
    {
45 9
        $this->methods = $methods;
46 9
        return $this;
47
    }
48
49 4
    public function setRestrictions(array $restrictions): self
50
    {
51 4
        $this->restrictions = $restrictions;
52 4
        return $this;
53
    }
54
55 9
    public function getRestrictions(): array
56
    {
57 9
        return $this->restrictions;
58
    }
59
60 1
    public function getHandler(): RequestHandlerInterface
61
    {
62 1
        return $this->handler;
63
    }
64
65 9
    public function getPath(): string
66
    {
67 9
        return $this->path;
68
    }
69
}