Completed
Push — master ( 3eb757...3bc7c8 )
by Oleg
03:46
created

GetResourcesAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authorization\Controller;
5
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\ServerRequestInterface;
8
use Psr\Http\Server\MiddlewareInterface;
9
use Psr\Http\Server\RequestHandlerInterface;
10
use SlayerBirden\DataFlowServer\Authorization\Service\ResourceManager;
11
use SlayerBirden\DataFlowServer\Stdlib\Validation\GeneralSuccessResponseFactory;
12
13
final class GetResourcesAction implements MiddlewareInterface
14
{
15
    /**
16
     * @var ResourceManager
17
     */
18
    private $resourceManager;
19
20 2
    public function __construct(ResourceManager $resourceManager)
21
    {
22 2
        $this->resourceManager = $resourceManager;
23 2
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 2
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
29
    {
30 2
        $resources = $this->resourceManager->getAllResources();
31 2
        $count = count($resources);
32 2
        return (new GeneralSuccessResponseFactory())('Success', 'resources', $resources, 200, $count);
33
    }
34
}
35