Passed
Push — master ( 3d58fd...651f47 )
by Edward
05:09
created

UniqueNumericAggregator   A

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