1 | <?php |
||
11 | final class Router implements MethodMatcher, WarmableInterface |
||
12 | { |
||
13 | /** @var MethodCollectionLoader */ |
||
14 | private $loader; |
||
15 | /** @var MethodCollection */ |
||
16 | private $collection; |
||
17 | /** @var MethodMatcher */ |
||
18 | private $matcher; |
||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $name; |
||
23 | /** @var ConfigCacheFactoryInterface */ |
||
24 | private $configCacheFactory; |
||
25 | private $options = []; |
||
26 | |||
27 | /** |
||
28 | * Router constructor. |
||
29 | * |
||
30 | * @param MethodCollectionLoader $loader |
||
31 | * @param string $name |
||
32 | * @param array $options |
||
33 | */ |
||
34 | 11 | public function __construct(MethodCollectionLoader $loader, $name, array $options = []) |
|
40 | |||
41 | /** |
||
42 | * @return MethodCollection |
||
43 | 11 | */ |
|
44 | 2 | public function getMethodCollection() |
|
52 | |||
53 | /** {@inheritdoc} */ |
||
54 | 9 | public function match($method) |
|
58 | 1 | ||
59 | 1 | /** |
|
60 | 1 | * Warms up the cache. |
|
61 | 1 | * |
|
62 | * @param string $cacheDir The cache directory |
||
63 | 1 | */ |
|
64 | public function warmUp($cacheDir) |
||
74 | |||
75 | /** |
||
76 | * Sets an option. |
||
77 | * |
||
78 | * @param string $key The key |
||
79 | * @param mixed $value The value |
||
80 | * |
||
81 | * @throws \InvalidArgumentException |
||
82 | */ |
||
83 | public function setOption($key, $value) |
||
89 | |||
90 | /** |
||
91 | * Gets an option value. |
||
92 | 1 | * |
|
93 | * @param string $key The key |
||
94 | 1 | * |
|
95 | 1 | * @return mixed The value |
|
96 | 1 | * |
|
97 | 1 | * @throws \InvalidArgumentException |
|
98 | */ |
||
99 | 1 | public function getOption($key) |
|
107 | 1 | ||
108 | /** |
||
109 | 1 | * Sets options. |
|
110 | 1 | * |
|
111 | * Available options: |
||
112 | 1 | * |
|
113 | 1 | * * cache_dir: The cache directory (or null to disable caching) |
|
114 | 1 | * * debug: Whether to enable debugging or not (false by default) |
|
115 | 1 | * |
|
116 | 1 | * @param array $options An array of options |
|
117 | 1 | * |
|
118 | 1 | * @throws \InvalidArgumentException When unsupported option is provided |
|
119 | 1 | */ |
|
120 | 11 | public function setOptions(array $options) |
|
144 | |||
145 | /** |
||
146 | 1 | * @return MethodMatcher |
|
147 | */ |
||
148 | 10 | private function getMatcher() |
|
183 | |||
184 | /** |
||
185 | * Provides the ConfigCache factory implementation, falling back to a |
||
186 | * default implementation if necessary. |
||
187 | * |
||
188 | * @return ConfigCacheFactoryInterface $configCacheFactory |
||
189 | */ |
||
190 | 9 | private function getConfigCacheFactory() |
|
198 | |||
199 | /** |
||
200 | * @param $key |
||
201 | */ |
||
202 | private function validateOption($key) |
||
208 | } |
||
209 |