Passed
Push — master ( a071d4...32677b )
by Felipe
02:03
created

RouteMatch::getHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of coisa/http.
4
 *
5
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace CoiSA\Http;
12
13
use Psr\Http\Server\RequestHandlerInterface;
14
15
/**
16
 * Interface RouterInterface
17
 *
18
 * @package CoiSA\Http
19
 */
20
final class RouteMatch implements RouteMatchInterface
21
{
22
    /**
23
     * @var RequestHandlerInterface
24
     */
25
    private $handler;
26
27
    /**
28
     * @var array|null
29
     */
30
    private $matches;
31
32
    /**
33
     * Router constructor.
34
     *
35
     * @param RequestHandlerInterface $notFoundHandler
36
     */
37
    public function __construct(RequestHandlerInterface $handler, ?array $matches = null)
38
    {
39
        $this->handler = $handler;
40
        $this->matches = $matches;
41
    }
42
43
    /**
44
     * @return bool
45
     */
46
    public function isSuccess(): bool
47
    {
48
        return !empty($this->matches);
49
    }
50
51
    /**
52
     * @return RequestHandlerInterface
53
     */
54
    public function getHandler(): RequestHandlerInterface
55
    {
56
        return $this->handler;
57
    }
58
59
    /**
60
     * @return array
61
     */
62
    public function getVariables(): array
63
    {
64
        return is_array($this->matches) ? $this->matches : [];
65
    }
66
}
67