Passed
Push — master ( 1c8d05...42c076 )
by Enjoys
01:48
created

Helpers::getHttpScheme()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 6
eloc 8
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 6
rs 9.2222
1
<?php
2
3
4
namespace Enjoys\AssetsCollector;
5
6
7
class Helpers
8
{
9
10 15
    static public function getHttpScheme(): string
11
    {
12 15
        $scheme = 'http';
13 15
        if (isset($_SERVER['HTTP_SCHEME'])) {
14 1
            return $_SERVER['HTTP_SCHEME'];
15
        }
16
17 14
        if (isset($_SERVER['HTTPS']) && \strtolower($_SERVER['HTTPS']) != 'off') {
18 1
            return 'https';
19
        }
20
21 13
        if (isset($_SERVER['SERVER_PORT']) && 443 == $_SERVER['SERVER_PORT']) {
22 1
            return 'https';
23
        }
24 12
        return $scheme;
25
    }
26
}