CasUser::getPassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 0
c 2
b 0
f 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace drupol\CasBundle\Security\Core\User;
6
7
/**
8
 * Class CasUser.
9
 */
10
final class CasUser implements CasUserInterface
11
{
12
    /**
13
     * The user storage.
14
     *
15
     * @var array<mixed>
16
     */
17
    private $storage;
18
19
    /**
20
     * CasUser constructor.
21
     *
22
     * @param array<mixed> $data
23
     */
24 10
    public function __construct(array $data)
25
    {
26 10
        $this->storage = $data;
27 10
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function eraseCredentials(): void
33
    {
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 3
    public function get(string $key, $default = null)
40
    {
41 3
        return $this->getStorage()[$key] ?? $default;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 1
    public function getAttribute(string $key, $default = null)
48
    {
49 1
        return $this->getStorage()['attributes'][$key] ?? $default;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function getAttributes(): array
56
    {
57 1
        return $this->get('attributes', []);
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getPassword()
64
    {
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 1
    public function getPgt(): ?string
71
    {
72 1
        return $this->get('proxyGrantingTicket');
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 1
    public function getRoles()
79
    {
80 1
        return ['ROLE_CAS_AUTHENTICATED'];
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function getSalt()
87
    {
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 1
    public function getUser(): string
94
    {
95 1
        return $this->get('user');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->get('user') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101 1
    public function getUsername()
102
    {
103 1
        return $this->getUser();
104
    }
105
106
    /**
107
     * Get the storage.
108
     *
109
     * @return array<mixed>
110
     */
111 4
    private function getStorage()
112
    {
113 4
        return $this->storage;
114
    }
115
}
116