Completed
Push — impl-EZP-26000-permission-look... ( 500ba3 )
by
unknown
26:49
created

PermissionInfo   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 5
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A canUser() 0 8 2
A getHash() 0 4 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Publish\Core\Repository\Values;
8
9
use eZ\Publish\API\Repository\Values\PermissionInfo as APIPermissionInfo;
10
11
class PermissionInfo extends APIPermissionInfo
12
{
13
    private $permissionMap;
14
15
    public function __construct(array $properties)
16
    {
17
        if (isset($properties['permissionMap'])) {
18
            $this->permissionMap = $properties['permissionMap'];
19
            unset($properties['permissionMap']);
20
        }
21
22
        parent::__construct($properties);
23
    }
24
25
    /**
26
     * @param string $function
27
     *
28
     * @return boolean
29
     */
30
    public function canUser($function)
31
    {
32
        if (isset($this->permissionMap['*'])) {
33
            return true;
34
        }
35
36
        return isset($this->permissionMap[$function]);
37
    }
38
39
    /**
40
     * @return mixed
41
     */
42
    public function getHash()
43
    {
44
        return $this->permissionMap;
45
    }
46
}
47