| Conditions | 3 |
| Paths | 1 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | 9 | public function connect(Application $app) |
|
| 14 | { |
||
| 15 | 9 | $resource = $app["controllers_factory"]; |
|
| 16 | |||
| 17 | 9 | $resource->get("/{type}", new GetResourceController($app["resourceful.schemas"], "application/schema+json")) |
|
| 18 | 9 | ->assert("type", ".+") |
|
| 19 | 9 | ->bind("schema"); |
|
| 20 | |||
| 21 | 9 | $resource->after(function (Request $request, Response $response, Application $app) { |
|
| 22 | 3 | if ($response->isSuccessful()) { |
|
| 23 | 2 | $schema = json_decode($response->getContent(), true); |
|
| 24 | 2 | $app["json-schema.describedBy"] = array_key_exists('$schema', $schema) |
|
| 25 | 1 | ? $schema['$schema'] |
|
| 26 | 1 | : $app["resourceful.defaultSchemaVersion"]; |
|
| 27 | } |
||
| 28 | 9 | }); |
|
| 29 | |||
| 30 | return $resource; |
||
| 31 | } |
||
| 32 | } |
||
| 33 |