1 | <?php |
||
7 | class MethodCollection implements \IteratorAggregate, \Countable |
||
8 | { |
||
9 | /** @var Route[] */ |
||
10 | private $routes = []; |
||
11 | /** |
||
12 | * @var ResourceInterface[] |
||
13 | */ |
||
14 | private $resources = []; |
||
15 | |||
16 | /** |
||
17 | * @param $method |
||
18 | * |
||
19 | * @return Route |
||
20 | * @throws \OutOfBoundsException |
||
21 | */ |
||
22 | 1 | public function get($method) |
|
30 | |||
31 | 2 | public function has($method) |
|
35 | |||
36 | 2 | public function add($method, Route $route) |
|
44 | |||
45 | 2 | public function replace($method, Route $route) |
|
51 | |||
52 | 2 | public function addPrefix($prefix) |
|
53 | { |
||
54 | 2 | if ('' === $prefix) { |
|
55 | 2 | return; |
|
56 | } |
||
57 | |||
58 | 2 | foreach ($this->routes as $name => $route) { |
|
59 | 2 | unset($this->routes[$name]); |
|
60 | 2 | $method = $prefix . $route->getMethod(); |
|
61 | 2 | $route->setMethod($method); |
|
62 | 2 | $this->routes[$method] = $route; |
|
63 | 2 | } |
|
64 | 2 | } |
|
65 | |||
66 | 2 | public function addContext($context) |
|
74 | |||
75 | 2 | public function addCollection(MethodCollection $collection) |
|
86 | |||
87 | 2 | public function all() |
|
91 | |||
92 | /** |
||
93 | * Returns an array of resources loaded to build this collection. |
||
94 | * |
||
95 | * @return ResourceInterface[] An array of resources |
||
96 | */ |
||
97 | 2 | public function getResources() |
|
101 | |||
102 | /** {@inheritdoc} */ |
||
103 | public function getIterator() |
||
107 | |||
108 | /** {@inheritdoc} */ |
||
109 | public function count() |
||
113 | |||
114 | /** |
||
115 | * @param ResourceInterface $resource |
||
116 | */ |
||
117 | 2 | public function addResource(ResourceInterface $resource) |
|
121 | } |
||
122 |