Failed Conditions
Push — master ( 276992...d29638 )
by Adrien
06:52
created

ExpenseClaimStatusIsNew::assert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
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 5
    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
27
    {
28 5
        $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 5
        $assertion = new StatusIsNew();
30
31 5
        return $assertion->assert($acl, $role, new ModelResource(ExpenseClaim::class, $object), $privilege);
32
    }
33
}
34