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