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

StatusIsNew::assert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Acl\Assertion;
6
7
use Application\DBAL\Types\ExpenseClaimStatusType;
8
use Zend\Permissions\Acl\Acl;
9
use Zend\Permissions\Acl\Assertion\AssertionInterface;
10
use Zend\Permissions\Acl\Resource\ResourceInterface;
11
use Zend\Permissions\Acl\Role\RoleInterface;
12
13
class StatusIsNew implements AssertionInterface
14
{
15
    /**
16
     * Assert that the expense claim is new (not processed yet)
17
     *
18
     * @param Acl $acl
19
     * @param RoleInterface $role
20
     * @param ResourceInterface $resource
21
     * @param string $privilege
22
     *
23
     * @return bool
24
     */
25 6
    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
26
    {
27 6
        $object = $resource->getInstance();
0 ignored issues
show
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

27
        /** @scrutinizer ignore-call */ 
28
        $object = $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

27
        /** @scrutinizer ignore-call */ 
28
        $object = $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...
28
29 6
        return $object->getStatus() === ExpenseClaimStatusType::NEW;
30
    }
31
}
32