Completed
Push — master ( cb0ced...7754cf )
by Edward
04:45
created

AggregatorCollection   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 29
ccs 0
cts 12
cp 0
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
    public function byName(string $name): ValueAggregatorInterface
16
    {
17
        switch ($name) {
18
            case self::MIN:
19
                return new MinAggregator;
20
21
            case self::MAX:
22
                return new MaxAggregator;
23
24
            case self::LENGTH:
25
                return new LengthAggregator;
26
27
            case self::AVG:
28
                return new AvgAggregator;
29
30
            case self::STDDEV:
31
                return new StdDevAggregator;
32
        }
33
34
        throw new Exception\AggregateFunctionNotFoundException($name);
35
    }
36
}
37