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

PermissionInfo::canUser()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
cc 2
eloc 4
nc 2
nop 1
rs 9.4285
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