Completed
Push — master ( 467d47...6f2bb4 )
by Anton
14s
created

AbstractIdentity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 0
cts 5
cp 0
c 0
b 0
f 0
rs 10
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
getPrivileges() 0 1 ?
A getId() 0 4 2
A hasPrivilege() 0 6 1
1
<?php
2
/**
3
 * Bluz Framework Component
4
 *
5
 * @copyright Bluz PHP Team
6
 * @link      https://github.com/bluzphp/framework
7
 */
8
9
declare(strict_types=1);
10
11
namespace Bluz\Auth;
12
13
use Bluz\Db\Row;
14
15
/**
16
 * Abstract class for Users\Row
17
 *
18
 * @package Bluz\Auth
19
 *
20
 * @property integer $id
21
 * @property string  $login
22
 * @property string  $email
23
 */
24
abstract class AbstractIdentity extends Row implements IdentityInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    abstract public function getPrivileges() : array;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getId() : ?int
35
    {
36
        return $this->id ? (int)$this->id : null;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function hasPrivilege($module, $privilege) : bool
43
    {
44
        $privileges = $this->getPrivileges();
45
46
        return in_array("$module:$privilege", $privileges, true);
47
    }
48
}
49