Failed Conditions
Push — master ( 978224...1c63e7 )
by Adrien
18:15
created

UserIsActive::assert()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.072

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10
cc 3
nc 2
nop 4
crap 3.072
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\Model\User;
8
use Ecodev\Felix\Acl\Assertion\NamedAssertion;
9
use Laminas\Permissions\Acl\Acl;
10
use Laminas\Permissions\Acl\Resource\ResourceInterface;
11
use Laminas\Permissions\Acl\Role\RoleInterface;
12
13
class UserIsActive implements NamedAssertion
14
{
15
    public function getName(): string
16
    {
17
        return "l'utilisateur est actif";
18
    }
19
20
    /**
21
     * Assert that the current user is active.
22
     *
23
     * @param \Application\Acl\Acl $acl
24
     * @param RoleInterface $role
25
     * @param ResourceInterface $resource
26
     * @param string $privilege
27
     *
28
     * @return bool
29
     */
30 2
    public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null)
31
    {
32 2
        $currentUser = User::getCurrent();
33 2
        if ($currentUser && $currentUser->getStatus() === User::STATUS_ACTIVE) {
34 2
            return true;
35
        }
36
37
        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

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