AbstractCredential   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 185
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 185
c 0
b 0
f 0
wmc 17
lcom 1
cbo 1
ccs 43
cts 43
cp 1
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getEntityId() 0 4 1
A getUsageType() 0 4 1
A getKeyNames() 0 4 1
A getPublicKey() 0 4 1
A getPrivateKey() 0 4 1
A getSecretKey() 0 4 1
A getCredentialContext() 0 4 1
A setCredentialContext() 0 6 1
A setEntityId() 0 6 1
A setKeyNames() 0 6 1
A addKeyName() 0 9 2
A setPrivateKey() 0 6 1
A setPublicKey() 0 6 1
A setSecretKey() 0 6 1
A setUsageType() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the LightSAML-Core package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace LightSaml\Credential;
13
14
use LightSaml\Credential\Context\CredentialContextSet;
15
use RobRichards\XMLSecLibs\XMLSecurityKey;
16
17
abstract class AbstractCredential implements CredentialInterface
18
{
19
    /** @var string */
20
    private $entityId;
21
22
    /** @var string */
23
    private $usageType;
24
25
    /** @var string[] */
26
    private $keyNames = array();
27
28
    /** @var XMLSecurityKey|null */
29
    private $publicKey;
30
31
    /** @var XMLSecurityKey|null */
32
    private $privateKey;
33
34
    /** @var string|null */
35
    private $secretKey;
36
37
    /** @var CredentialContextSet */
38
    private $credentialContext;
39
40 27
    public function __construct()
41
    {
42 27
        $this->credentialContext = new CredentialContextSet();
43 27
    }
44
45
    /**
46
     * @return string
47
     */
48 14
    public function getEntityId()
49
    {
50 14
        return $this->entityId;
51
    }
52
53
    /**
54
     * One of UsageType constants.
55
     *
56
     * @return string|null
57
     */
58 12
    public function getUsageType()
59
    {
60 12
        return $this->usageType;
61
    }
62
63
    /**
64
     * @return string[]
65
     */
66 3
    public function getKeyNames()
67
    {
68 3
        return $this->keyNames;
69
    }
70
71
    /**
72
     * @return XMLSecurityKey|null
73
     */
74 10
    public function getPublicKey()
75
    {
76 10
        return $this->publicKey;
77
    }
78
79
    /**
80
     * @return XMLSecurityKey|null
81
     */
82 15
    public function getPrivateKey()
83
    {
84 15
        return $this->privateKey;
85
    }
86
87
    /**
88
     * @return string|null
89
     */
90 1
    public function getSecretKey()
91
    {
92 1
        return $this->secretKey;
93
    }
94
95
    /**
96
     * @return CredentialContextSet
97
     */
98 11
    public function getCredentialContext()
99
    {
100 11
        return $this->credentialContext;
101
    }
102
103
    /**
104
     * @param CredentialContextSet $credentialContext
105
     *
106
     * @return AbstractCredential
107
     */
108 8
    public function setCredentialContext(CredentialContextSet $credentialContext)
109
    {
110 8
        $this->credentialContext = $credentialContext;
111
112 8
        return $this;
113
    }
114
115
    /**
116
     * @param string $entityId
117
     *
118
     * @return AbstractCredential
119
     */
120 20
    public function setEntityId($entityId)
121
    {
122 20
        $this->entityId = $entityId;
123
124 20
        return $this;
125
    }
126
127
    /**
128
     * @param \string[] $keyNames
129
     *
130
     * @return AbstractCredential
131
     */
132 22
    public function setKeyNames(array $keyNames)
133
    {
134 22
        $this->keyNames = $keyNames;
0 ignored issues
show
Documentation Bug introduced by
It seems like $keyNames of type array<integer,object<string>> is incompatible with the declared type array<integer,string> of property $keyNames.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
135
136 22
        return $this;
137
    }
138
139
    /**
140
     * @param string $keyName
141
     *
142
     * @return AbstractCredential
143
     */
144 9
    public function addKeyName($keyName)
145
    {
146 9
        $keyName = trim($keyName);
147 9
        if ($keyName) {
148 9
            $this->keyNames[] = $keyName;
149
        }
150
151 9
        return $this;
152
    }
153
154
    /**
155
     * @param null|XMLSecurityKey $privateKey
156
     *
157
     * @return AbstractCredential
158
     */
159 21
    public function setPrivateKey(XMLSecurityKey $privateKey)
160
    {
161 21
        $this->privateKey = $privateKey;
162
163 21
        return $this;
164
    }
165
166
    /**
167
     * @param null|XMLSecurityKey $publicKey
168
     *
169
     * @return AbstractCredential
170
     */
171 22
    public function setPublicKey(XMLSecurityKey $publicKey)
172
    {
173 22
        $this->publicKey = $publicKey;
174
175 22
        return $this;
176
    }
177
178
    /**
179
     * @param null|string $secretKey
180
     *
181
     * @return AbstractCredential
182
     */
183 1
    public function setSecretKey($secretKey)
184
    {
185 1
        $this->secretKey = $secretKey;
186
187 1
        return $this;
188
    }
189
190
    /**
191
     * @param string $usageType
192
     *
193
     * @return AbstractCredential
194
     */
195 11
    public function setUsageType($usageType)
196
    {
197 11
        $this->usageType = $usageType;
198
199 11
        return $this;
200
    }
201
}
202