Passed
Push — master ( a70ee3...b8386d )
by Sébastien
02:12
created

ContredanseUser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
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 7
    public function __construct(string $identity, array $roles = [], array $details = [])
29
    {
30 7
        $this->identity = $identity;
31 7
        $this->details  = $details;
32 7
        $this->roles    = $roles;
33 7
    }
34
35
    public function getIdentity(): string
36
    {
37
        return $this->identity;
38
    }
39
40
    /**
41
     * @return string[]
42
     */
43 7
    public function getRoles(): array
44
    {
45 7
        return $this->roles;
46
    }
47
48
    /**
49
     * @param mixed $default
50
     *
51
     * @return mixed|null|string
52
     */
53 7
    public function getDetail(string $name, $default = null)
54
    {
55 7
        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