FinkokEnvironment   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 12
c 3
b 0
f 0
dl 0
loc 43
ccs 17
cts 17
cp 1
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isDevelopment() 0 3 1
A makeDevelopment() 0 3 1
A endpoint() 0 8 2
A isProduction() 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 102
    private function __construct(Definitions\Environment $environment)
13
    {
14 102
        $this->environment = $environment;
15
    }
16
17 100
    public static function makeDevelopment(): self
18
    {
19 100
        return new self(Definitions\Environment::development());
20
    }
21
22 2
    public static function makeProduction(): self
23
    {
24 2
        return new self(Definitions\Environment::production());
25
    }
26
27 3
    public function isDevelopment(): bool
28
    {
29 3
        return $this->environment->isDevelopment();
30
    }
31
32 3
    public function isProduction(): bool
33
    {
34 3
        return $this->environment->isProduction();
35
    }
36
37 1
    public function server(): string
38
    {
39 1
        return $this->environment->value();
40
    }
41
42 97
    public function endpoint(Definitions\Services $service): string
43
    {
44 97
        $environment = $this->environment;
45 97
        if ($service->isManifest()) {
46 11
            $environment = (new Definitions\EnvironmentManifest($environment->index()));
47
        }
48
49 97
        return rtrim($environment->value(), '/') . '/' . ltrim($service->value(), '/');
50
    }
51
}
52