Issues (20)

src/Route.php (1 issue)

Labels
Severity
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)
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_MATCH, expecting T_VARIABLE on line 16 at column 32
Loading history...
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