Passed
Push — main ( 3a2337...ad42a0 )
by Daniel
04:45
created

UserAclRetrieveApplication   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 18
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A run() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Api\User;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Uxmp\Core\Api\AbstractApiApplication;
10
use Uxmp\Core\Api\Lib\Middleware\SessionValidatorMiddleware;
11
use Uxmp\Core\Component\User\PrivilegeCheckerInterface;
12
use Uxmp\Core\Orm\Model\UserInterface;
13
14
/**
15
 * Delivers the user's acl
16
 */
17
final class UserAclRetrieveApplication extends AbstractApiApplication
18
{
19 1
    public function __construct(
20
        private readonly PrivilegeCheckerInterface $privilegeChecker,
21
    ) {
22
    }
23
24 1
    protected function run(
25
        ServerRequestInterface $request,
26
        ResponseInterface $response,
27
        array $args
28
    ): ResponseInterface {
29
        /** @var UserInterface $user */
30 1
        $user = $request->getAttribute(SessionValidatorMiddleware::USER);
31
32 1
        return $this->asJson(
33
            $response,
34 1
            $this->privilegeChecker->getAcl($user)
35
        );
36
    }
37
}
38