UserIsActive   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
dl 0
loc 23
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assert() 0 8 3
A getName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\Enum\UserStatus;
8
use Application\Model\User;
9
use Ecodev\Felix\Acl\Assertion\NamedAssertion;
10
use Laminas\Permissions\Acl\Acl;
11
use Laminas\Permissions\Acl\Resource\ResourceInterface;
12
use Laminas\Permissions\Acl\Role\RoleInterface;
13
14
class UserIsActive implements NamedAssertion
15
{
16
    public function getName(): string
17
    {
18
        return 'je suis actif';
19
    }
20
21
    /**
22
     * Assert that the current user is active.
23
     *
24
     * @param \Application\Acl\Acl $acl
25
     * @param string $privilege
26
     *
27
     * @return bool
28
     */
29 2
    public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null)
30
    {
31 2
        $currentUser = User::getCurrent();
32 2
        if ($currentUser && $currentUser->getStatus() === UserStatus::Active) {
33 2
            return true;
34
        }
35
36
        return $acl->reject('the current user is not active');
0 ignored issues
show
Bug introduced by
The method reject() does not exist on Laminas\Permissions\Acl\Acl. It seems like you code against a sub-type of Laminas\Permissions\Acl\Acl such as Ecodev\Felix\Acl\Acl. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        return $acl->/** @scrutinizer ignore-call */ reject('the current user is not active');
Loading history...
37
    }
38
}
39