RoutesDelegator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 29 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authorization\Factory;
5
6
use Interop\Container\ContainerInterface;
7
use SlayerBirden\DataFlowServer\Authentication\Middleware\TokenMiddleware;
8
use SlayerBirden\DataFlowServer\Authorization\Controller\GetPermissionHistoryAction;
9
use SlayerBirden\DataFlowServer\Authorization\Controller\GetResourcesAction;
10
use SlayerBirden\DataFlowServer\Authorization\Controller\SavePermissionsAction;
11
use SlayerBirden\DataFlowServer\Domain\Middleware\SetOwnerMiddleware;
12
use Zend\Expressive\Application;
13
use Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware;
14
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
15
16
final class RoutesDelegator implements DelegatorFactoryInterface
17
{
18
    /**
19
     * @inheritdoc
20
     */
21 144
    public function __invoke(
22
        ContainerInterface $container,
23
        $name,
24
        callable $callback,
25
        array $options = null
26
    ): Application {
27
        /** @var $app Application */
28 144
        $app = $callback();
29
30 144
        $app->get('/resources', [
31 144
            TokenMiddleware::class,
32
            GetResourcesAction::class
33 144
        ], 'get_resources');
34
35 144
        $app->put('/permissions/{id:\d+}', [
36 144
            TokenMiddleware::class,
37
            'UserResourceMiddleware',
38
            BodyParamsMiddleware::class,
39
            SetOwnerMiddleware::class,
40
            SavePermissionsAction::class
41 144
        ], 'save_permissions');
42
43 144
        $app->get('/history', [
44 144
            TokenMiddleware::class,
45
            GetPermissionHistoryAction::class
46 144
        ], 'get_permission_history');
47
48 144
        return $app;
49
    }
50
}
51