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

AggregatorCollection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 29
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A byName() 0 20 6
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Runtime\Aggregator;
5
6
final class AggregatorCollection
7
{
8
9
    private const MIN = 'min';
10
    private const MAX = 'max';
11
    private const LENGTH = 'length';
12
    private const AVG = 'avg';
13
    private const STDDEV = 'stddev';
14
15 6
    public function byName(string $name): ValueAggregatorInterface
16
    {
17
        switch ($name) {
18 6
            case self::MIN:
19 1
                return new MinAggregator;
20
21 5
            case self::MAX:
22 1
                return new MaxAggregator;
23
24 4
            case self::LENGTH:
25 1
                return new LengthAggregator;
26
27 3
            case self::AVG:
28 1
                return new AvgAggregator;
29
30 2
            case self::STDDEV:
31 1
                return new StdDevAggregator;
32
        }
33
34 1
        throw new Exception\AggregateFunctionNotFoundException($name);
35
    }
36
}
37