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

UserAclRetrieveApplication::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 11
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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