AggregatorCollection   A
last analyzed

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