AbstractIdentity::getId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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