Failed Conditions
Push — master ( 7e6aaf...81a376 )
by Adrien
03:56
created

AccountHasNoTransaction::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 10
cc 2
nc 2
nop 4
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\Model\Account;
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 AccountHasNoTransaction implements NamedAssertion
14
{
15
    public function getName(): string
16
    {
17
        return "le compte et ses sous-comptes n'ont aucune écritures";
18
    }
19
20
    /**
21
     * Assert that the account, or any of its subaccounts, have no transaction at all.
22
     *
23
     * @param \Application\Acl\Acl $acl
24
     * @param string $privilege
25
     *
26
     * @return bool
27
     */
28
    public function assert(Acl $acl, ?RoleInterface $role = null, ?ResourceInterface $resource = null, $privilege = null)
29
    {
30
        /** @var Account $account */
31
        $account = $resource->getInstance();
0 ignored issues
show
Bug introduced by
The method getInstance() does not exist on null. ( Ignorable by Annotation )

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

31
        /** @scrutinizer ignore-call */ 
32
        $account = $resource->getInstance();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
33
        if (!_em()->getRepository(Account::class)->hasTransaction($account)) {
34
            return true;
35
        }
36
37
        return $acl->reject('the account, or its sub-accounts, have transaction lines');
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 account, or its sub-accounts, have transaction lines');
Loading history...
38
    }
39
}
40