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

PrivilegeChecker::getAcl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\User;
6
7
use Uxmp\Core\Api\Lib\Enum\AclEnum;
8
use Uxmp\Core\Orm\Model\UserInterface;
9
10
/**
11
 * Checks for specific user privileges
12
 */
13
final class PrivilegeChecker implements PrivilegeCheckerInterface
14
{
15
    /**
16
     * Returns `true` if the user is an admin user
17
     */
18 1
    public function isAdmin(UserInterface $user): bool
19
    {
20 1
        return in_array(
21 1
            AclEnum::USER_EDIT->value,
22 1
            $this->getAcl($user),
23
            true,
24
        );
25
    }
26
27
    /**
28
     * Returns user's acl
29
     *
30
     * @return array<int>
31
     */
32 1
    public function getAcl(
33
        UserInterface $user,
34
    ): array {
35
        return [
36 1
            AclEnum::USER_EDIT->value,
37
        ];
38
    }
39
}
40