EnvironmentFactory::create()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GusApi\Environment;
6
7
use GusApi\Exception\InvalidEnvironmentNameException;
8
9
final class EnvironmentFactory
10
{
11
    public static function create(string $environment): EnvironmentInterface
12
    {
13
        if ('prod' === $environment) {
14
            return new ProdEnvironment();
15
        }
16
17
        if ('dev' === $environment) {
18
            return new DevEnvironment();
19
        }
20
21
        throw new InvalidEnvironmentNameException(sprintf('Invalid environment %s', $environment));
22
    }
23
}
24