Completed
Pull Request — master (#46)
by Ekin
06:38
created

src/Http/Origin.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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