1 | <?php |
||
12 | class Matcher |
||
13 | { |
||
14 | /** |
||
15 | * Routes collection |
||
16 | * @var RouteCollection |
||
17 | */ |
||
18 | protected $routes; |
||
19 | |||
20 | public function __construct(RouteCollection $routes) |
||
24 | |||
25 | /** |
||
26 | * Find the route that match the given path from the routes |
||
27 | * @param string $path |
||
28 | * @return Route |
||
29 | */ |
||
30 | public function match($path) |
||
35 | |||
36 | /** |
||
37 | * Find the route that match given request |
||
38 | * @param ServerRequestInterface $request |
||
39 | * @return Route |
||
40 | */ |
||
41 | public function matchRequest(ServerRequestInterface $request) |
||
45 | |||
46 | /** |
||
47 | * Do match |
||
48 | * @param string|ServerRequestInterface $pathOrRequest |
||
49 | * @return Route |
||
50 | */ |
||
51 | protected function doMatch($pathOrRequest) |
||
60 | |||
61 | /** |
||
62 | * @param ServerRequestInterface $request |
||
63 | * @throws MethodNotAllowedException |
||
64 | * @throws RouteNotFoundException |
||
65 | * @return Route |
||
66 | */ |
||
67 | protected function findRouteFromRequest(ServerRequestInterface $request) |
||
87 | |||
88 | /** |
||
89 | * @param string $path |
||
90 | * @throws RouteNotFoundException |
||
91 | * @return Route |
||
92 | */ |
||
93 | protected function findRoute($path) |
||
102 | |||
103 | /** |
||
104 | * Checks whether the route matches the current request host |
||
105 | * @param Route $route |
||
106 | * @param ServerRequestInterface $request |
||
107 | * @return boolean |
||
108 | */ |
||
109 | protected static function matchHost(Route $route, $request) |
||
123 | |||
124 | /** |
||
125 | * Checks whether the route matches the current request method |
||
126 | * @param Route $route |
||
127 | * @param ServerRequestInterface $request |
||
128 | * @return boolean |
||
129 | */ |
||
130 | protected static function matchMethod(Route $route, $request) |
||
137 | |||
138 | /** |
||
139 | * Checks whether the route matches the scheme |
||
140 | * @param Route $route |
||
141 | * @param ServerRequestInterface $request |
||
142 | * @return boolean |
||
143 | */ |
||
144 | protected static function matchSchema(Route $route, $request) |
||
151 | |||
152 | /** |
||
153 | * Checks whether the route matches the given path |
||
154 | * @param string $path |
||
155 | * @param Route $route |
||
156 | * @return boolean |
||
157 | */ |
||
158 | protected static function matchPath($path, Route $route) |
||
169 | |||
170 | /** |
||
171 | * Computes route parameters |
||
172 | * @param Route $route |
||
173 | * @return array |
||
174 | */ |
||
175 | protected static function computeRouteParameters(Route $route) |
||
182 | } |