Passed
Push — master ( f2694b...92ebee )
by Pol
12:01
created

CasUser::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 10
ccs 0
cts 7
cp 0
crap 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A CasUser::getStorage() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcPhp\CasBundle\Security\Core\User;
6
7
final class CasUser implements CasUserInterface
8
{
9
    /**
10
     * The user storage.
11
     *
12
     * @var array<mixed>
13
     */
14
    private array $storage;
15
16
    /**
17
     * CasUser constructor.
18
     *
19
     * @param array<mixed> $data
20
     */
21
    public function __construct(array $data)
22
    {
23
        $this->storage = $data;
24 9
    }
25
26 9
    /**
27 9
     * {@inheritdoc}
28
     */
29
    public function eraseCredentials(): void
30
    {
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function get(string $key, $default = null)
37
    {
38
        return $this->getStorage()[$key] ?? $default;
39 3
    }
40
41 3
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getAttribute(string $key, $default = null)
45
    {
46
        return $this->getStorage()['attributes'][$key] ?? $default;
47 1
    }
48
49 1
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getAttributes(): array
53
    {
54
        return $this->get('attributes', []);
55 1
    }
56
57 1
    /**
58
     * {@inheritdoc}
59
     */
60
    public function getPassword(): ?string
61
    {
62
        return null;
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getPgt(): ?string
69
    {
70
        return $this->get('proxyGrantingTicket');
71 1
    }
72
73 1
    /**
74
     * {@inheritdoc}
75
     */
76
    public function getRoles(): array
77
    {
78
        return ['ROLE_CAS_AUTHENTICATED'];
79 1
    }
80
81 1
    /**
82
     * {@inheritdoc}
83
     */
84
    public function getSalt(): ?string
85
    {
86
        return null;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function getUsername(): string
93
    {
94
        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...
95
    }
96
97
    /**
98
     * Get the storage.
99
     *
100
     * @return array<mixed>
101
     */
102
    private function getStorage(): array
103
    {
104
        return $this->storage;
105
    }
106
}
107