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

Factory::getRange()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
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
}