AbstractIdentity   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 23
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasPrivilege() 0 5 1
A getId() 0 3 2
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