Test Setup Failed
Pull Request — master (#46)
by Ekin
06:26
created

Origin::getHttpOrigin()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace ekinhbayar\GitAmp\Http;
4
5
class Origin
6
{
7
    private array $configuration;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
8
9 4
    public function __construct(array $configuration)
10
    {
11 4
        $this->configuration = $configuration;
12
    }
13
14 4
    public function get(): string
15
    {
16 4
        if (isset($this->configuration['ssl'])) {
17 2
            return $this->getHttpsOrigin();
18
        }
19
20 2
        return $this->getHttpOrigin();
21
    }
22
23 2
    private function getHttpsOrigin(): string
24
    {
25 2
        $origin = 'https://' . $this->configuration['hostname'];
26
27 2
        if ($this->configuration['ssl']['port'] !== 443) {
28 1
            $origin .= ':' . $this->configuration['ssl']['port'];
29
        }
30
31 2
        return $origin;
32
    }
33
34 2
    private function getHttpOrigin(): string
35
    {
36 2
        $origin = 'http://' . $this->configuration['hostname'];
37
38 2
        if ($this->configuration['expose']['port'] !== 80) {
39 1
            $origin .= ':' . $this->configuration['expose']['port'];
40
        }
41
42 2
        return $origin;
43
    }
44
}
45