Completed
Pull Request — master (#3)
by Бабичев
01:51
created

Route::methodValid()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 3
nc 5
nop 1
dl 0
loc 5
rs 9.2
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 4
1
<?php
2
3
namespace Bavix\Router;
4
5
class Route implements Routable
6
{
7
8
    /**
9
     * @var Match
10
     */
11
    protected $match;
12
13
    /**
14
     * @param Match $match
15
     */
16 2
    public function __construct(Match $match)
17
    {
18 2
        $this->match = $match;
19 2
    }
20
21
    /**
22
     * @return string
23
     */
24
    public function getProtocol(): string
25
    {
26
        return $this->match->getProtocol();
27
    }
28
29
    /**
30
     * @return string
31
     */
32
    public function getHost(): string
33
    {
34
        return $this->match->getHost();
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getName(): string
41
    {
42
        return $this->match->getRule()->getName();
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getPathValue(): string
49
    {
50
        return $this->match->getRule()->getPath()->getValue();
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getPath(): string
57
    {
58
        return $this->match->getPath();
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getPathPattern(): string
65
    {
66
        return $this->match->getRule()->getPath()->getPattern();
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getPattern(): string
73
    {
74
        return $this->match->getPattern();
75
    }
76
77
    /**
78
     * @return array
79
     */
80 2
    public function getAttributes(): array
81
    {
82 2
        return $this->match->getAttributes();
83
    }
84
85
    /**
86
     * @return array
87
     */
88
    public function getDefaults(): array
89
    {
90
        return $this->match->getRule()->getDefaults();
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function getGroups(): array
97
    {
98
        return $this->match->getGroups();
99
    }
100
101
    /**
102
     * @return array
103
     */
104
    public function getMethods(): array
105
    {
106
        return $this->match->getRule()->getMethods();
107
    }
108
109
    /**
110
     * @return array
111
     */
112
    public function __sleep(): array
113
    {
114
        return ['match'];
115
    }
116
117
    /**
118
     * @inheritdoc
119
     */
120
    public function serialize(): string
121
    {
122
        return \serialize($this->match);
123
    }
124
125
    /**
126
     * @inheritdoc
127
     */
128
    public function unserialize($serialized): void
129
    {
130
        $this->match = \unserialize($serialized, (array)null);
131
    }
132
133
    /**
134
     * @inheritdoc
135
     */
136
    public function jsonSerialize(): array
137
    {
138
        return [
139
            'protocol' => $this->getProtocol(),
140
            'host' => $this->getHost(),
141
            'name' => $this->getName(),
142
            'path' => $this->getPath(),
143
            'pathValue' => $this->getPathValue(),
144
            'pathPattern' => $this->getPathPattern(),
145
            'pattern' => $this->getPattern(),
146
            'attributes' => $this->getAttributes(),
147
            'defaults' => $this->getDefaults(),
148
            'methods' => $this->getMethods(),
149
        ];
150
    }
151
152
}
153