Conditions | 3 |
Paths | 3 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 2 | public function load($resource, $type = null) |
|
18 | { |
||
19 | 2 | if ($this->loaded) { |
|
20 | 1 | throw new \LogicException('Endpoint loader is already loaded'); |
|
21 | } |
||
22 | |||
23 | 2 | $collection = new RouteCollection(); |
|
24 | 2 | foreach ($this->endpoints as $name => $endpoint) { |
|
25 | // prepare a new route |
||
26 | 2 | $path = $endpoint['path']; |
|
27 | 2 | $defaults = $endpoint['defaults']; |
|
28 | 2 | $route = new Route($path, $defaults); |
|
29 | 2 | $route->setMethods('POST'); |
|
30 | |||
31 | 2 | $collection->add($name, $route); |
|
32 | 2 | } |
|
33 | |||
34 | 2 | $this->loaded = true; |
|
35 | |||
36 | 2 | return $collection; |
|
37 | } |
||
38 | |||
54 |