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

PrivilegeChecker   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAcl() 0 5 1
A isAdmin() 0 6 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