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

AbstractIdentity::getId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
nc 2
dl 0
loc 4
ccs 0
cts 2
cp 0
c 0
b 0
f 0
cc 2
eloc 2
nop 0
crap 6
rs 10
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