Completed
Push — master ( 7bc3e7...153a01 )
by Pol
01:48
created

CasUser::eraseCredentials()   A

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 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
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
use LogicException;
8
9
/**
10
 * Class CasUser.
11
 */
12
final class CasUser implements CasUserInterface
13
{
14
    /**
15
     * The user storage.
16
     *
17
     * @var array
18
     */
19
    private $storage;
20
21
    /**
22
     * CasUser constructor.
23
     *
24
     * @param array $data
25
     */
26 11
    public function __construct(array $data)
27
    {
28 11
        $this->storage = $data;
29 11
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function eraseCredentials(): void
35
    {
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41 3
    public function get(string $key, $default = null)
42
    {
43 3
        return $this->getStorage()[$key] ?? $default;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function getAttribute(string $key, $default = null)
50
    {
51 1
        return $this->getStorage()['attributes'][$key] ?? $default;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function getAttributes(): array
58
    {
59 1
        return $this->get('attributes', []);
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function getPassword()
66
    {
67
    }
68
69
    /**
70
     * {@inheritdoc}
71
     */
72 1
    public function getPgt(): ?string
73
    {
74 1
        return $this->get('proxyGrantingTicket');
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80 1
    public function getRoles()
81
    {
82 1
        return ['ROLE_CAS_AUTHENTICATED'];
83
    }
84
85
    /**
86
     * {@inheritdoc}
87
     */
88 1
    public function getSalt()
89
    {
90 1
        throw new LogicException('Not implemented.');
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96 1
    public function getUser(): string
97
    {
98 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...
99
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104 1
    public function getUsername()
105
    {
106 1
        return $this->getUser();
107
    }
108
109
    /**
110
     * Get the storage.
111
     *
112
     * @return array
113
     */
114 4
    private function getStorage()
115
    {
116 4
        return $this->storage;
117
    }
118
}
119