MayViewCv   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 6
dl 0
loc 24
c 0
b 0
f 0
ccs 0
cts 6
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A assert() 0 8 5
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @license MIT
7
 * @copyright  2013 - 2016 Cross Solution <http://cross-solution.de>
8
 */
9
  
10
/** */
11
namespace Cv\Acl\Assertion;
12
13
use Cv\Entity\Cv;
14
use Auth\Entity\UserInterface;
15
use Core\Entity\PermissionsInterface;
16
use Cv\Entity\CvInterface;
17
use Cv\Entity\Status;
18
use Laminas\Permissions\Acl\Acl;
19
use Laminas\Permissions\Acl\Assertion\AssertionInterface;
20
use Laminas\Permissions\Acl\Resource\ResourceInterface;
21
use Laminas\Permissions\Acl\Role\RoleInterface;
22
23
/**
24
 * ${CARET}
25
 *
26
 * @author Mathias Gelhausen <[email protected]>
27
 * @todo write test
28
 */
29
class MayViewCv implements AssertionInterface
30
{
31
    /**
32
     * Returns true if and only if the assertion conditions are met
33
     *
34
     * This method is passed the ACL, Role, Resource, and privilege to which the authorization query applies. If the
35
     * $role, $resource, or $privilege parameters are null, it means that the query applies to all Roles, Resources, or
36
     * privileges, respectively.
37
     *
38
     * @param  Acl               $acl
39
     * @param  RoleInterface     $role
40
     * @param  ResourceInterface $resource
41
     * @param  string            $privilege
42
     *
43
     * @return bool
44
     */
45
    public function assert(Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null)
46
    {
47
        /* @var ResourceInterface|Cv $resource */
48
        return $role instanceof UserInterface
49
               && $resource instanceof CvInterface
50
               && 'view' == $privilege
51
               && ($resource->getPermissions()->isGranted($role, PermissionsInterface::PERMISSION_VIEW)
52
                   || Status::PUBLIC_TO_ALL == (string) $resource->getStatus());
0 ignored issues
show
Bug introduced by
The method getStatus() does not exist on Cv\Entity\CvInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Cv\Entity\CvInterface. ( Ignorable by Annotation )

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

52
                   || Status::PUBLIC_TO_ALL == (string) $resource->/** @scrutinizer ignore-call */ getStatus());
Loading history...
Bug introduced by
The method getStatus() 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 Applications\Entity\Application or Jobs\Entity\JobInterface or Cv\Entity\Cv. ( Ignorable by Annotation )

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

52
                   || Status::PUBLIC_TO_ALL == (string) $resource->/** @scrutinizer ignore-call */ getStatus());
Loading history...
53
    }
54
}
55