AvgAggregator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A aggregateNumericData() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Runtime\Aggregator;
6
7
use Remorhaz\JSON\Path\Value\LiteralScalarValue;
8
use Remorhaz\JSON\Data\Value\ScalarValueInterface;
9
use Remorhaz\JSON\Data\Value\ValueInterface;
10
11
use function array_sum;
12
use function count;
13
14
final class AvgAggregator extends NumericAggregator
15
{
16
17 2
    protected function aggregateNumericData(array $dataList, ScalarValueInterface ...$elements): ?ValueInterface
18
    {
19 2
        return empty($dataList)
20
            // @codeCoverageIgnoreStart
21
            ? null
22
            // @codeCoverageIgnoreEnd
23 2
            : new LiteralScalarValue(array_sum($dataList) / count($dataList));
24
    }
25
}
26