Passed
Branch feature/v2 (61dd95)
by Valentin
05:53
created

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 17
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getRange() 0 10 2
1
<?php
2
3
namespace Spiral\Statistics\Extract\Range;
4
5
use Spiral\Statistics\Exceptions\InvalidExtractRangeException;
6
use Spiral\Statistics\Extract\RangeInterface;
7
8
class Factory
9
{
10
    /**
11
     * @param string $range
12
     * @return RangeInterface
13
     */
14
    public static function getRange(string $range): RangeInterface
15
    {
16
        if (!in_array($range, RangeInterface::RANGES)) {
17
            throw new InvalidExtractRangeException($range);
18
        }
19
20
        $className = 'Spiral\\Statistics\\Extract\\Range\\' . ucfirst($range) . 'Range';
21
22
        return new $className;
23
    }
24
}