Route   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 159
Duplicated Lines 0 %

Test Coverage

Coverage 10.42%

Importance

Changes 0
Metric Value
wmc 18
eloc 31
dl 0
loc 159
ccs 5
cts 48
cp 0.1042
rs 10
c 0
b 0
f 0

18 Methods

Rating   Name   Duplication   Size   Complexity  
A unserialize() 0 3 1
A __construct() 0 3 1
A getPattern() 0 3 1
A getMethod() 0 3 1
A getDefaults() 0 3 1
A getPathValue() 0 3 1
A getProtocol() 0 3 1
A getPathPattern() 0 3 1
A getPath() 0 3 1
A getName() 0 3 1
A jsonSerialize() 0 14 1
A getAttributes() 0 3 1
A __sleep() 0 3 1
A getGroups() 0 3 1
A getExtends() 0 3 1
A serialize() 0 3 1
A getMethods() 0 3 1
A getHost() 0 3 1
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 4
    public function __construct(Match $match)
17
    {
18 4
        $this->match = $match;
19 4
    }
20
21
    public function getMethod(): string
22
    {
23
        return $this->match->getMethod();
24
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function getGroups(): array
30
    {
31
        return $this->match->getGroups();
32
    }
33
34
    /**
35
     * @return array
36
     */
37
    public function __sleep(): array
38
    {
39
        return ['match'];
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function serialize(): string
46
    {
47
        return \serialize($this->match);
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function unserialize($serialized): void
54
    {
55
        $this->match = \unserialize($serialized, (array)null);
56
    }
57
58
    /**
59
     * @inheritdoc
60
     */
61
    public function jsonSerialize(): array
62
    {
63
        return [
64
            'protocol' => $this->getProtocol(),
65
            'host' => $this->getHost(),
66
            'name' => $this->getName(),
67
            'path' => $this->getPath(),
68
            'pathValue' => $this->getPathValue(),
69
            'pathPattern' => $this->getPathPattern(),
70
            'pattern' => $this->getPattern(),
71
            'extends' => $this->getExtends(),
72
            'attributes' => $this->getAttributes(),
73
            'defaults' => $this->getDefaults(),
74
            'methods' => $this->getMethods(),
75
        ];
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    public function getProtocol(): string
82
    {
83
        return $this->match->getProtocol();
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    public function getHost(): string
90
    {
91
        return $this->match->getHost();
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    public function getName(): string
98
    {
99
        return $this->match->getRule()->getName();
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    public function getPath(): string
106
    {
107
        return $this->match->getPath();
108
    }
109
110
    /**
111
     * @return string
112
     */
113
    public function getPathValue(): string
114
    {
115
        return $this->match->getRule()->getPath()->getValue();
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    public function getPathPattern(): string
122
    {
123
        return $this->match->getRule()->getPath()->getPattern();
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    public function getPattern(): string
130
    {
131
        return $this->match->getPattern();
132
    }
133
134
    /**
135
     * @return array
136
     */
137
    public function getExtends(): array
138
    {
139
        return $this->match->getRule()->getExtends();
140
    }
141
142
    /**
143
     * @return array
144
     */
145 4
    public function getAttributes(): array
146
    {
147 4
        return $this->match->getAttributes();
148
    }
149
150
    /**
151
     * @return array
152
     */
153
    public function getDefaults(): array
154
    {
155
        return $this->match->getRule()->getDefaults();
156
    }
157
158
    /**
159
     * @return null|array
160
     */
161
    public function getMethods(): ?array
162
    {
163
        return $this->match->getRule()->getMethods();
164
    }
165
166
}
167