Passed
Push — master ( 20eafa...9b902c )
by Sam
07:54
created

ExpenseClaimStatusIsNew::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 4
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
c 0
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\ExpenseClaim;
9
use Zend\Permissions\Acl\Acl;
10
use Zend\Permissions\Acl\Assertion\AssertionInterface;
11
use Zend\Permissions\Acl\Resource\ResourceInterface;
12
use Zend\Permissions\Acl\Role\RoleInterface;
13
14
class ExpenseClaimStatusIsNew implements AssertionInterface
15
{
16
    /**
17
     * Assert that the accounting document's expense claim is new (not processed yet)
18
     *
19
     * @param Acl $acl
20
     * @param RoleInterface $role
21
     * @param ResourceInterface $resource
22
     * @param string $privilege
23
     *
24
     * @return bool
25
     */
26 4
    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
27
    {
28 4
        $object = $resource->getInstance()->getExpenseClaim();
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

28
        $object = $resource->/** @scrutinizer ignore-call */ getInstance()->getExpenseClaim();

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...
Bug introduced by
The method getInstance() does not exist on Zend\Permissions\Acl\Resource\ResourceInterface. It seems like you code against a sub-type of Zend\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

28
        $object = $resource->/** @scrutinizer ignore-call */ getInstance()->getExpenseClaim();
Loading history...
29
30 4
        if (!$object) {
31
            return true;
32
        }
33
34 4
        $assertion = new StatusIsNew();
35
36 4
        return $assertion->assert($acl, $role, new ModelResource(ExpenseClaim::class, $object), $privilege);
37
    }
38
}
39