|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Scriptotek\Alma\Users; |
|
4
|
|
|
|
|
5
|
|
|
use Scriptotek\Alma\Client; |
|
6
|
|
|
use Scriptotek\Alma\Model\Model; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Iterable collection of statistics resources. |
|
10
|
|
|
*/ |
|
11
|
|
|
class UserStatistics extends Model |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Get the user's statistics. |
|
15
|
|
|
* |
|
16
|
|
|
* @return Statistic |
|
17
|
|
|
*/ |
|
18
|
|
|
public function getStatistics() |
|
19
|
|
|
{ |
|
20
|
|
|
$stats = array(); |
|
21
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
22
|
|
|
array_push($stats,$statistic); |
|
23
|
|
|
} |
|
24
|
|
|
return $stats; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Get Stats By Type Code. |
|
29
|
|
|
* |
|
30
|
|
|
* @return Array of Statistics. |
|
31
|
|
|
*/ |
|
32
|
|
View Code Duplication |
public function getStatsByTypeCode($typeCode) |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
$stats = array(); |
|
35
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
36
|
|
|
$statcat_type = $statistic->category_type; |
|
37
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
38
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
39
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
$type_code = $statcat_type->value; |
|
42
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
43
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
44
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
if ($type_code == $typeCode) { |
|
47
|
|
|
array_push($stats,$statistic); |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
return $stats; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get Stats by Type Desc. |
|
55
|
|
|
* |
|
56
|
|
|
* @return Array of statistics. |
|
57
|
|
|
*/ |
|
58
|
|
View Code Duplication |
public function getStatsByTypeDesc($typeDesc) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$stats = array(); |
|
61
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
62
|
|
|
$statcat_type = $statistic->category_type; |
|
63
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
64
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
65
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
66
|
|
|
|
|
67
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
68
|
|
|
$type_desc = $statcat_type->desc; |
|
69
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
70
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
if ($type_desc == $typeDesc) { |
|
73
|
|
|
array_push($stats,$statistic); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
return $stats; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Get Stats by Category Code. |
|
81
|
|
|
* |
|
82
|
|
|
* @return Array of Statistics. |
|
83
|
|
|
*/ |
|
84
|
|
View Code Duplication |
public function getStatsByCategoryCode($categoryCode) |
|
|
|
|
|
|
85
|
|
|
{ |
|
86
|
|
|
$stats = array(); |
|
87
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
88
|
|
|
$statcat_type = $statistic->category_type; |
|
89
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
90
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
91
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
94
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
95
|
|
|
$category_code = $statcat_cat->value; |
|
96
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
if ($category_code == $categoryCode) { |
|
99
|
|
|
array_push($stats,$statistic); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
return $stats; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Get Stats by Category Desc. |
|
107
|
|
|
* |
|
108
|
|
|
* @return Array of Statistics. |
|
109
|
|
|
*/ |
|
110
|
|
View Code Duplication |
public function getStatsByCategoryDesc($categoryDesc) |
|
|
|
|
|
|
111
|
|
|
{ |
|
112
|
|
|
$stats = array(); |
|
113
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
114
|
|
|
$statcat_type = $statistic->category_type; |
|
115
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
116
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
117
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
120
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
121
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
122
|
|
|
$category_desc = $statcat_cat->desc; |
|
123
|
|
|
|
|
124
|
|
|
if ($category_desc == $categoryDesc) { |
|
125
|
|
|
array_push($stats,$statistic); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
return $stats; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Get Stats by Segment Type. |
|
133
|
|
|
* |
|
134
|
|
|
* @return Array of Statistics. |
|
135
|
|
|
*/ |
|
136
|
|
View Code Duplication |
public function getStatsBySegmentType($segmentType) |
|
|
|
|
|
|
137
|
|
|
{ |
|
138
|
|
|
$stats = array(); |
|
139
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
140
|
|
|
$statcat_type = $statistic->category_type; |
|
141
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
142
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
143
|
|
|
$segment_type = $statistic->segment_type; |
|
144
|
|
|
|
|
145
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
146
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
147
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
148
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
149
|
|
|
|
|
150
|
|
|
if ($segment_type == $segmentType) { |
|
151
|
|
|
array_push($stats,$statistic); |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
return $stats; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Search Stats by Note. |
|
159
|
|
|
* |
|
160
|
|
|
* @return Array of Statistics. |
|
161
|
|
|
*/ |
|
162
|
|
View Code Duplication |
public function searchStatsByNote($note) |
|
|
|
|
|
|
163
|
|
|
{ |
|
164
|
|
|
$stats = array(); |
|
165
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
166
|
|
|
$statcat_type = $statistic->category_type; |
|
167
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
168
|
|
|
$statcat_note = $statistic->statistic_note; |
|
169
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
170
|
|
|
|
|
171
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
172
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
173
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
174
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
if (preg_match("/$note/i", $statcat_note)) { |
|
177
|
|
|
array_push($stats,$statistic); |
|
178
|
|
|
} |
|
179
|
|
|
} |
|
180
|
|
|
return $stats; |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Search Stats by Type Code. |
|
185
|
|
|
* |
|
186
|
|
|
* @return Array of Statistics. |
|
187
|
|
|
*/ |
|
188
|
|
View Code Duplication |
public function searchStatsByTypeCode($typeCode) |
|
|
|
|
|
|
189
|
|
|
{ |
|
190
|
|
|
$stats = array(); |
|
191
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
192
|
|
|
$statcat_type = $statistic->category_type; |
|
193
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
194
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
195
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
196
|
|
|
|
|
197
|
|
|
$type_code = $statcat_type->value; |
|
198
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
199
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
200
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
201
|
|
|
|
|
202
|
|
|
if (preg_match("/$typeCode/i", $type_code)) { |
|
203
|
|
|
array_push($stats,$statistic); |
|
204
|
|
|
} |
|
205
|
|
|
} |
|
206
|
|
|
return $stats; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
/** |
|
210
|
|
|
* Search Stats by Type Code. |
|
211
|
|
|
* |
|
212
|
|
|
* @return Array of Statistics. |
|
213
|
|
|
*/ |
|
214
|
|
View Code Duplication |
public function searchStatsByTypeDesc($typeDesc) |
|
|
|
|
|
|
215
|
|
|
{ |
|
216
|
|
|
$stats = array(); |
|
217
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
218
|
|
|
$statcat_type = $statistic->category_type; |
|
219
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
220
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
221
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
222
|
|
|
|
|
223
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
224
|
|
|
$type_desc = $statcat_type->desc; |
|
225
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
226
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
227
|
|
|
|
|
228
|
|
|
if (preg_match("/$typeDesc/i", $type_desc)) { |
|
229
|
|
|
array_push($stats,$statistic); |
|
230
|
|
|
} |
|
231
|
|
|
} |
|
232
|
|
|
return $stats; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* Search Stats by Type Code. |
|
237
|
|
|
* |
|
238
|
|
|
* @return Array of Statistics. |
|
239
|
|
|
*/ |
|
240
|
|
View Code Duplication |
public function searchStatsByCategoryCode($categoryCode) |
|
|
|
|
|
|
241
|
|
|
{ |
|
242
|
|
|
$stats = array(); |
|
243
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
244
|
|
|
$statcat_type = $statistic->category_type; |
|
245
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
246
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
247
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
250
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
251
|
|
|
$category_code = $statcat_cat->value; |
|
252
|
|
|
$category_desc = $statcat_cat->desc; |
|
|
|
|
|
|
253
|
|
|
|
|
254
|
|
|
if (preg_match("/$categoryCode/i", $category_code)) { |
|
255
|
|
|
array_push($stats,$statistic); |
|
256
|
|
|
} |
|
257
|
|
|
} |
|
258
|
|
|
return $stats; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
/** |
|
262
|
|
|
* Search Stats by Type Code. |
|
263
|
|
|
* |
|
264
|
|
|
* @return Array of Statistics. |
|
265
|
|
|
*/ |
|
266
|
|
View Code Duplication |
public function searchStatsByCategoryDesc($categoryDesc) |
|
|
|
|
|
|
267
|
|
|
{ |
|
268
|
|
|
$stats = array(); |
|
269
|
|
|
foreach ($this->data as $statistic) { |
|
|
|
|
|
|
270
|
|
|
$statcat_type = $statistic->category_type; |
|
271
|
|
|
$statcat_cat = $statistic->statistic_category; |
|
272
|
|
|
$statcat_note = $statistic->statistic_note; |
|
|
|
|
|
|
273
|
|
|
$segment_type = $statistic->segment_type; |
|
|
|
|
|
|
274
|
|
|
|
|
275
|
|
|
$type_code = $statcat_type->value; |
|
|
|
|
|
|
276
|
|
|
$type_desc = $statcat_type->desc; |
|
|
|
|
|
|
277
|
|
|
$category_code = $statcat_cat->value; |
|
|
|
|
|
|
278
|
|
|
$category_desc = $statcat_cat->desc; |
|
279
|
|
|
|
|
280
|
|
|
if (preg_match("/$categoryDesc/i", $category_desc)) { |
|
281
|
|
|
array_push($stats,$statistic); |
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
return $stats; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
|
|
288
|
|
|
|
|
289
|
|
|
/* |
|
290
|
|
|
public function all($status = 'ACTIVE') |
|
291
|
|
|
{ |
|
292
|
|
|
$ids = [$this->data->primary_id]; |
|
293
|
|
|
foreach ($this->data->user_identifier as $identifier) { |
|
294
|
|
|
if (is_null($status) || $identifier->status == $status) { |
|
295
|
|
|
$ids[] = $identifier->value; |
|
296
|
|
|
} |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
return $ids; |
|
300
|
|
|
} |
|
301
|
|
|
*/ |
|
302
|
|
|
|
|
303
|
|
|
} |
|
304
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.