Failed Conditions
Push — master ( 6a8bd6...5def7d )
by Adrien
08:40
created

ExpenseClaimStatusIsNew::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
nc 2
nop 4
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
crap 2.0116
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\Acl\ModelResource;
8
use Application\Model\AccountingDocument;
9
use Application\Model\ExpenseClaim;
10
use Laminas\Permissions\Acl\Acl;
11
use Laminas\Permissions\Acl\Assertion\AssertionInterface;
12
use Laminas\Permissions\Acl\Resource\ResourceInterface;
13
use Laminas\Permissions\Acl\Role\RoleInterface;
14
15
class ExpenseClaimStatusIsNew implements AssertionInterface
16
{
17
    /**
18
     * Assert that the accounting document's expense claim is new (not processed yet)
19
     *
20
     * @param \Application\Acl\Acl $acl
21
     * @param RoleInterface $role
22
     * @param ResourceInterface $resource
23
     * @param string $privilege
24
     *
25
     * @return bool
26
     */
27 3
    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
28
    {
29
        /** @var AccountingDocument $instance */
30 3
        $instance = $resource->getInstance();
0 ignored issues
show
Bug introduced by
The method getInstance() does not exist on Laminas\Permissions\Acl\Resource\ResourceInterface. It seems like you code against a sub-type of Laminas\Permissions\Acl\Resource\ResourceInterface such as Application\Acl\ModelResource. ( Ignorable by Annotation )

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

30
        /** @scrutinizer ignore-call */ 
31
        $instance = $resource->getInstance();
Loading history...
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

30
        /** @scrutinizer ignore-call */ 
31
        $instance = $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...
31 3
        $expenseClaim = $instance->getExpenseClaim();
32
33 3
        if (!$expenseClaim) {
34
            return true;
35
        }
36
37 3
        $assertion = new StatusIsNew();
38
39 3
        return $assertion->assert($acl, $role, new ModelResource(ExpenseClaim::class, $expenseClaim), $privilege);
40
    }
41
}
42