Completed
Push — master ( 9be0de...4e104c )
by Enrico
06:20
created

SchemaControllerProvider::connect()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 1
crap 2.0116
1
<?php
2
namespace Resourceful;
3
4
use Silex\Api\ControllerProviderInterface;
5
use Symfony\Component\HttpFoundation\Request;
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
8
use Silex\Application;
9
10
class SchemaControllerProvider implements ControllerProviderInterface
11
{
12 2
    public function connect(Application $app)
13
    {
14
    	// ensure that SchemaControllerProvider is called once
15 2
    	if( isset($app['schema.controller'])){
16
			$app->abort(501,'Sorry, you can create only one schema endpoint');
17
		} else {
18
			$app['schema.controller'] = function(){
19
				return new ReadResourceController('schema');
20
			};
21
		}
22
23 2
        $controllers = $app["controllers_factory"];
24
		
25 2
        $controllers->get("/{id}", 'schema.controller:read')->bind("schema")
26 2
			->after(new DescribedBySchemaHandler)
27
		;
28
			
29 2
        return $controllers;
30
    }
31
}
32