Passed
Push — master ( 651f47...1b6630 )
by Edward
03:03
created

AvgAggregator   A

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