|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2017 SURFnet B.V. |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace OpenConext\Profile\Value\AttributeAggregation; |
|
20
|
|
|
|
|
21
|
|
|
use Assert\Assertion; |
|
22
|
|
|
|
|
23
|
|
|
final class AttributeAggregationAttribute |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var int |
|
27
|
|
|
*/ |
|
28
|
|
|
private $id; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
private $userId; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
private $accountType; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
private $linkedId; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @var string |
|
47
|
|
|
*/ |
|
48
|
|
|
private $logoPath; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @var string |
|
52
|
|
|
*/ |
|
53
|
|
|
private $connectUrl; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @var bool |
|
57
|
|
|
*/ |
|
58
|
|
|
private $isConnected = false; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param int $id |
|
62
|
|
|
* @param string $userId |
|
63
|
|
|
* @param string $accountType |
|
64
|
|
|
* @param string $linkedId |
|
65
|
|
|
* @param string $logoPath |
|
66
|
|
|
* @param string $connectUrl |
|
67
|
|
|
* @param bool $isConnected |
|
68
|
|
|
*/ |
|
69
|
|
|
public function __construct( |
|
70
|
|
|
$id, |
|
71
|
|
|
$userId, |
|
72
|
|
|
$accountType, |
|
73
|
|
|
$linkedId, |
|
74
|
|
|
$logoPath, |
|
75
|
|
|
$connectUrl, |
|
76
|
|
|
$isConnected |
|
77
|
|
|
) { |
|
78
|
|
|
$this->id = $id; |
|
79
|
|
|
$this->userId = $userId; |
|
80
|
|
|
$this->accountType = $accountType; |
|
81
|
|
|
$this->linkedId = $linkedId; |
|
82
|
|
|
$this->logoPath = $logoPath; |
|
83
|
|
|
$this->connectUrl = $connectUrl; |
|
84
|
|
|
$this->isConnected = $isConnected; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public static function fromConfig( |
|
88
|
|
|
AttributeAggregationAttributeConfiguration $enabledAttribute, |
|
89
|
|
|
$isConnected, |
|
90
|
|
|
$id, |
|
91
|
|
|
$userId, |
|
92
|
|
|
$linkedId = null |
|
93
|
|
|
) { |
|
94
|
|
|
return new self( |
|
95
|
|
|
$id, |
|
96
|
|
|
$userId, |
|
97
|
|
|
$enabledAttribute->getAccountType(), |
|
98
|
|
|
$linkedId, |
|
99
|
|
|
$enabledAttribute->getLogoPath(), |
|
100
|
|
|
$enabledAttribute->getConnectUrl(), |
|
101
|
|
|
$isConnected |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
public static function fromApiResponse(array $attributeData) |
|
106
|
|
|
{ |
|
107
|
|
|
Assertion::keyExists($attributeData, 'id', 'No id found on attribute'); |
|
108
|
|
|
Assertion::integer($attributeData['id'], 'Id should be integer'); |
|
109
|
|
|
|
|
110
|
|
|
Assertion::keyExists($attributeData, 'urn', 'No userId name id found on attribute'); |
|
111
|
|
|
Assertion::string($attributeData['urn'], 'userId name id Id should be a string'); |
|
112
|
|
|
|
|
113
|
|
|
Assertion::keyExists($attributeData, 'accountType', 'No account type found on attribute'); |
|
114
|
|
|
Assertion::string($attributeData['accountType'], 'Account type should be a string'); |
|
115
|
|
|
|
|
116
|
|
|
Assertion::keyExists($attributeData, 'linkedId', 'No linked id found on attribute'); |
|
117
|
|
|
Assertion::string($attributeData['linkedId'], 'Linked id should be a string'); |
|
118
|
|
|
|
|
119
|
|
|
return new self( |
|
120
|
|
|
$attributeData['id'], |
|
121
|
|
|
$attributeData['urn'], |
|
122
|
|
|
$attributeData['accountType'], |
|
123
|
|
|
$attributeData['linkedId'], |
|
124
|
|
|
'', |
|
125
|
|
|
'', |
|
126
|
|
|
'', |
|
|
|
|
|
|
127
|
|
|
true |
|
|
|
|
|
|
128
|
|
|
); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return string |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getAccountType() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->accountType; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return string |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getLinkedId() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->linkedId; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @return string |
|
149
|
|
|
*/ |
|
150
|
|
|
public function getLogoPath() |
|
151
|
|
|
{ |
|
152
|
|
|
return $this->logoPath; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return string |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getConnectUrl() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->connectUrl; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @return bool |
|
165
|
|
|
*/ |
|
166
|
|
|
public function isConnected() |
|
167
|
|
|
{ |
|
168
|
|
|
return $this->isConnected; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return int |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getId() |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->id; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
public function getUserNameId() |
|
180
|
|
|
{ |
|
181
|
|
|
return $this->userId; |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: