| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 51 | 3 | public function getBaseUrl(): string |
|
| 52 | { |
||
| 53 | 3 | $hostname = $_ENV['HOSTNAME']; |
|
| 54 | 3 | $port = (int) $_ENV['PORT']; |
|
| 55 | 3 | $ssl = ((bool) $_ENV['SSL']) === true; |
|
| 56 | |||
| 57 | 3 | $protocol = ($ssl === true) |
|
| 58 | 2 | ? 'https' |
|
| 59 | 1 | : 'http'; |
|
| 60 | |||
| 61 | 3 | $port_string = ''; |
|
| 62 | if ( |
||
| 63 | 3 | $port !== 0 && |
|
| 64 | 3 | !in_array($port, [80, 443], true) |
|
| 65 | ) { |
||
| 66 | 1 | $port_string = sprintf(':%d', $port); |
|
| 67 | } |
||
| 68 | |||
| 69 | 3 | return sprintf( |
|
| 70 | 3 | '%s://%s%s%s', |
|
| 71 | $protocol, |
||
| 72 | $hostname, |
||
| 73 | $port_string, |
||
| 74 | 3 | $this->getApiBasePath() |
|
| 75 | ); |
||
| 78 |