ContredanseUser::getRoles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Security;
6
7
use Zend\Expressive\Authentication\UserInterface;
8
9
class ContredanseUser implements UserInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $identity;
15
    /**
16
     * @var array|string[]
17
     */
18
    private $details;
19
    /**
20
     * @var array|string[]
21
     */
22
    private $roles;
23
24
    /**
25
     * @param string[] $roles
26
     * @param string[] $details
27
     */
28 8
    public function __construct(string $identity, array $roles = [], array $details = [])
29
    {
30 8
        $this->identity = $identity;
31 8
        $this->details  = $details;
32 8
        $this->roles    = $roles;
33 8
    }
34
35
    public function getIdentity(): string
36
    {
37
        return $this->identity;
38
    }
39
40
    /**
41
     * @return string[]
42
     */
43 8
    public function getRoles(): array
44
    {
45 8
        return $this->roles;
46
    }
47
48
    /**
49
     * @param mixed $default
50
     *
51
     * @return mixed|null|string
52
     */
53 8
    public function getDetail(string $name, $default = null)
54
    {
55 8
        return $this->details[$name] ?? $default;
56
    }
57
58
    /**
59
     * Get all additional user details, if any.
60
     */
61
    public function getDetails(): array
62
    {
63
        return $this->details;
64
    }
65
}
66