UniqueNumericAggregator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 20
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A findNumericElements() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Runtime\Aggregator;
6
7
use Remorhaz\JSON\Data\Value\ScalarValueInterface;
8
use Remorhaz\JSON\Data\Value\ValueInterface;
9
10
abstract class UniqueNumericAggregator extends NumericAggregator
11
{
12
13
    /**
14
     * @param ValueInterface $value
15
     * @return ScalarValueInterface[]
16
     */
17 2
    protected function findNumericElements(ValueInterface $value): array
18
    {
19 2
        $elements = [];
20 2
        $uniqueDataList = [];
21 2
        foreach (parent::findNumericElements($value) as $element) {
22 2
            if (in_array($element->getData(), $uniqueDataList, true)) {
23 1
                continue;
24
            }
25 2
            $uniqueDataList[] = $element->getData();
26 2
            $elements[] = $element;
27
        }
28
29 2
        return $elements;
30
    }
31
}
32