Route::name()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace N1215\Hakudo;
5
6
use Psr\Http\Server\RequestHandlerInterface;
7
use N1215\Http\RequestMatcher\RequestMatcherInterface;
8
use N1215\Http\RequestMatcher\RequestMatchResultInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
11
final class Route
12
{
13
    /** @var string  */
14
    private $name;
15
16
    /** @var RequestMatcherInterface  */
17
    private $matcher;
18
19
    /** @var RequestHandlerInterface  */
20
    private $handler;
21
22 6
    public function __construct(RequestMatcherInterface $matcher, RequestHandlerInterface $handler, string $name = null)
23
    {
24 6
        $this->name = $name;
25 6
        $this->matcher = $matcher;
26 6
        $this->handler = $handler;
27 6
    }
28
29 2
    public function getName(): ?string
30
    {
31 2
        return $this->name;
32
    }
33
34 1
    public function name(string $name): self
35
    {
36 1
        $this->name = $name;
37 1
        return $this;
38
    }
39
40 3
    public function match(ServerRequestInterface $request): RequestMatchResultInterface
41
    {
42 3
        return $this->matcher->match($request);
43
    }
44
45 2
    public function getHandler(): RequestHandlerInterface
46
    {
47 2
        return $this->handler;
48
    }
49
}
50