Completed
Pull Request — master (#11)
by Carlos C
03:41
created

FinkokEnvironment   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 45
ccs 18
cts 18
cp 1
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A isDevelopment() 0 3 1
A makeDevelopment() 0 3 1
A endpoint() 0 8 2
A isProduction() 0 3 1
A __construct() 0 3 1
A makeProduction() 0 3 1
A server() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\Finkok;
6
7
class FinkokEnvironment
8
{
9
    /** @var Definitions\Environment */
10
    private $environment;
11
12 32
    private function __construct(Definitions\Environment $environment)
13
    {
14 32
        $this->environment = $environment;
15 32
    }
16
17
    /** @return static */
18 30
    public static function makeDevelopment(): self
19
    {
20 30
        return new self(Definitions\Environment::development());
21
    }
22
23
    /** @return static */
24 2
    public static function makeProduction(): self
25
    {
26 2
        return new self(Definitions\Environment::production());
27
    }
28
29 3
    public function isDevelopment(): bool
30
    {
31 3
        return $this->environment->isDevelopment();
32
    }
33
34 3
    public function isProduction(): bool
35
    {
36 3
        return $this->environment->isProduction();
37
    }
38
39 1
    public function server(): string
40
    {
41 1
        return $this->environment->value();
42
    }
43
44 27
    public function endpoint(Definitions\Services $service): string
45
    {
46 27
        $environment = $this->environment;
47 27
        if ($service->isManifest()) {
48 3
            $environment = (new Definitions\EnvironmentManifest($environment->index()));
49
        }
50
51 27
        return $environment->value() . $service->value();
52
    }
53
}
54