Completed
Pull Request — master (#24)
by
unknown
05:53 queued 03:09
created

UserStatistics   B

Complexity

Total Complexity 45

Size/Duplication

Total Lines 327
Duplicated Lines 24.77 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 81
loc 327
rs 8.8
c 0
b 0
f 0
wmc 45
lcom 1
cbo 3

17 Methods

Rating   Name   Duplication   Size   Complexity  
A getStatistics() 0 8 2
A get() 0 8 2
A getStatistic() 0 11 4
A addStatisticRaw() 0 23 1
A addStatistic() 0 33 1
A removeStatistic() 0 19 4
A updateStatistic() 0 6 1
A getStatsByTypeCode() 11 11 3
A getStatsByTypeDesc() 10 10 3
A getStatsByCategoryCode() 10 10 3
A getStatsByCategoryDesc() 10 10 3
A getStatsBySegmentType() 0 10 3
A searchStatsByNote() 0 10 3
A searchStatsByTypeCode() 10 10 3
A searchStatsByTypeDesc() 10 10 3
A searchStatsByCategoryCode() 10 10 3
A searchStatsByCategoryDesc() 10 10 3

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like UserStatistics often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use UserStatistics, and based on these observations, apply Extract Interface, too.

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 Array of Statistics.
17
     */
18
    public function getStatistics()
19
    {
20
        $stats = array();
21
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
22
            $stats[] = $statistic;
23
        }
24
        return $stats;
25
    }
26
27
    /**
28
     * Get the user's statistics.
29
     * 
30
     * @return array of statistics.
31
     */
32
    public function get()
33
    {
34
        $stats = array();
35
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
36
            $stats[] = $statistic;
37
        }
38
        return $stats;
39
    }
40
41
    /**
42
    * Get a statistic.
43
    *
44
    * @param $typeCode code of the category type.
45
    * @param $categoryCode code of the statistical category.
46
    *
47
    * @return Statistic.
0 ignored issues
show
Documentation introduced by
The doc-type Statistic. could not be parsed: Unknown type name "Statistic." at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
48
    */
49
    public function getStatistic($typeCode,$categoryCode)
50
    {
51
        $stats = array();
52
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
53
            if (($statistic->category_type->value == $typeCode) && 
54
                ($statistic->statistic_category->value == $categoryCode)) {
55
                $stats[] = $statistic;
56
            }
57
        }
58
        return $stats;
59
    }
60
61
    /**
62
    * Add a user statistic with no regard to existing Types and Categories.
63
    *
64
    * @param string $typeCode code of the category type.
65
    * @param string $typeDesc description of the category type.
66
    * @param string $categoryCode code of the statistical category.
67
    * @param string $categoryDesc description of the statistical category.
68
    * @param string $note free text description of the statistic.
69
    * @param string $segment_type (Internal|External)
70
    *
71
    * @return Statistic
72
    */
73
    public function addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$segment_type,$note)
74
    {
75
        # Create the new statistic object
76
        $stat_obj = (object) [
77
            'statistic_category' => (object) [
78
                'value' => $categoryCode,
79
                'desc'  => $categoryDesc,
80
            ],
81
            'category_type' => (object) [
82
                'value' => $typeCode,
83
                'desc'  => $typeDesc,
84
            ],
85
            'statistic_note' => $note,
86
            'segment_type'   => $segment_type,
87
        ];
88
89
        # Add the object to the user
90
        $this->data[] = $stat_obj;
91
92
        /*  Not Sure this is quite right or needed. */
93
        #return Statistic::make($this->client,$stat_obj);
94
        #return($this->data);
95
    }
96
97
    /**
98
    * Add a user statistic based upon existing Types and Categories.
99
    *
100
    * @param string $typeCode code of the category type.
101
    * @param string $categoryCode code of the statistical category.
102
    *
103
    * @return Statistic
104
    */
105
    public function addStatistic($typeCode,$categoryCode,$segmentType,$note)
106
    {
107
        //* TODO HERE *//
108
109
        /* Logic: */
110
        /* Lookup both $typeCode and $categoryCode in codetable */
111
        /* Obtain information (code/description) from both code tables. */
112
        /* If found and ok, add the statistic to the user */
113
114
        /* Code Tables used:
115
            Code Table; UserStatisticalTypes
116
            Code Table: UserStatCategories
117
        */
118
119
        # Note need some error checking etc. here.
120
121
        # Get the Type and Category Descriptions for the codes from the code tables.
122
        $stat = $this->client->conf->codetables->get('UserStatisticalTypes')->getRowByCode($typeCode);
123
        $typeDesc = $stat[0]->description;
124
125
        $stat = $this->client->conf->codetables->get('UserStatCategories')->getRowByCode($categoryCode);
126
        $categoryDesc = $stat[0]->description;
127
        #
128
        # These are temporary for testing.
129
        #$typeDesc = 'Test';
130
        #$categoryDesc = 'Test';
131
        
132
        # Add the statistic:
133
        $this->addStatisticRaw($typeCode,$typeDesc,$categoryCode,$categoryDesc,$segmentType,$note);
134
135
        # For debugging:
136
        #print "TypeCode: $typeCode\nTypeDesc: $typeDesc\nCategoryCode: $categoryCode\nCategoryDesc: $categoryDesc\n";
137
    }
138
139
    /**
140
    * Delete a user statistic.
141
    *
142
    * @param string $typeCode code of the category type.
143
    * @param string $categoryCode code of the statistical category.
144
    */
145
    public function removeStatistic($typeCode,$categoryCode)
146
    {
147
        # Old way:
148
        #$max = sizeof($this->data);
149
        #for($i = 0; $i < $max; $i++) {
150
        #    if (($this->data[$i]->category_type->value == $typeCode) && ($this->data[$i]->statistic_category->value == $categoryCode)) {
151
        #        unset($this->data[$i]);
152
        #        $ret = true;
153
        #    }
154
        #}
155
156
        # New way: (Thanks Rick!)
157
        foreach($this->data as $key => $row) {
158
            if (($row->category_type->value == $typeCode) && ($row->statistic_category->value == $categoryCode)) {
159
                array_splice($this->data, $key, 1);
160
            }
161
        }
162
        return;
163
    }
164
165
    /**
166
    * Update a user statistic.
167
    *
168
    */
169
    public function updateStatistic($fromTypeCode,$fromCategoryCode,$toTypeCode,$toCategoryCode,$segmentType,$note)
170
    {
171
        /* Remove "from" statistic, then add "to" statistic */
172
        $this->removeStatistic($fromTypeCode,$fromCategoryCode);
173
        $this->addStatistic($toTypeCode,$toCategoryCode,$segmentType,$note);
174
    }
175
176
    /**
177
    * Get Stats By Type Code.
178
    *
179
    * @return Array of Statistics.
180
    */
181 View Code Duplication
    public function getStatsByTypeCode($typeCode)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
182
    {
183
        $stats = array();
184
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
185
            if ($statistic->category_type->value == $typeCode) {
186
                array_push($stats,$statistic);
187
            }
188
    
189
        }
190
        return $stats;
191
    } 
192
193
    /**
194
    * Get Stats by Type Desc.
195
    *
196
    * @return Array of statistics.
197
    */
198 View Code Duplication
    public function getStatsByTypeDesc($typeDesc)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
199
    {
200
        $stats = array();
201
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
202
            if ($statistic->category_type->desc == $typeDesc) {
203
                array_push($stats,$statistic);
204
            }
205
        }
206
        return $stats;
207
    }
208
209
    /**
210
    * Get Stats by Category Code.
211
    *
212
    * @return Array of Statistics.
213
    */
214 View Code Duplication
    public function getStatsByCategoryCode($categoryCode)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
215
    {
216
        $stats = array();
217
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
218
            if ($statistic->statistic_category->value == $categoryCode) {
219
                array_push($stats,$statistic);
220
            }
221
        }
222
        return $stats;
223
    }
224
225
    /**
226
    * Get Stats by Category Desc.
227
    *
228
    * @return Array of Statistics.
229
    */
230 View Code Duplication
    public function getStatsByCategoryDesc($categoryDesc)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
    {
232
        $stats = array();
233
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
234
            if ($statistic->statistic_category->desc == $categoryDesc) {
235
                array_push($stats,$statistic);
236
            }
237
        }
238
        return $stats;
239
    }
240
241
    /**
242
    * Get Stats by Segment Type.
243
    *
244
    * @return Array of Statistics.
245
    */
246
    public function getStatsBySegmentType($segmentType)
247
    {
248
        $stats = array();
249
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
250
            if ($statistic->segment_type == $segmentType) {
251
                array_push($stats,$statistic);
252
            }
253
        }
254
        return $stats;
255
    }  
256
257
    /**
258
    * Search Stats by Note.
259
    *
260
    * @return Array of Statistics.
261
    */
262
    public function searchStatsByNote($note)
263
    {
264
        $stats = array();
265
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
266
            if (preg_match("/$note/i", $statistic->statistic_note)) {
267
                array_push($stats,$statistic);
268
            }
269
        }
270
        return $stats;
271
    }
272
273
    /** 
274
    * Search Stats by Type Code.
275
    *
276
    * @return Array of Statistics.
277
    */
278 View Code Duplication
    public function searchStatsByTypeCode($typeCode)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
279
    {
280
        $stats = array();
281
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
282
            if (preg_match("/$typeCode/i", $statistic->category_type->value)) {
283
                array_push($stats,$statistic);
284
            }
285
        }
286
        return $stats;
287
    }
288
289
    /**
290
    * Search Stats by Type Code.
291
    *
292
    * @return Array of Statistics.
293
    */
294 View Code Duplication
    public function searchStatsByTypeDesc($typeDesc)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
295
    {
296
        $stats = array();
297
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
298
            if (preg_match("/$typeDesc/i", $statistic->category_type->desc)) {
299
                array_push($stats,$statistic);
300
            }
301
        }
302
        return $stats;
303
    }
304
305
    /**
306
    * Search Stats by Type Code.
307
    *
308
    * @return Array of Statistics.
309
    */
310 View Code Duplication
    public function searchStatsByCategoryCode($categoryCode)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
311
    {
312
        $stats = array();
313
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
314
            if (preg_match("/$categoryCode/i", $statistic->statistic_category->value)) {
315
                array_push($stats,$statistic);
316
            }
317
        }
318
        return $stats;
319
    }
320
321
    /**
322
    * Search Stats by Type Code.
323
    *
324
    * @return Array of Statistics.
325
    */
326 View Code Duplication
    public function searchStatsByCategoryDesc($categoryDesc)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
327
    {
328
        $stats = array();
329
        foreach ($this->data as $statistic) {
0 ignored issues
show
Bug introduced by
The expression $this->data of type object<stdClass>|array is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. 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:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
330
            if (preg_match("/$categoryDesc/i", $statistic->statistic_category->desc)) {
331
                array_push($stats,$statistic);
332
            }
333
        }
334
        return $stats;
335
    }
336
337
}
338