AOEpeople /
asdis
| 1 | <?php |
||
| 2 | namespace Aoe\Asdis\Domain\Model; |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Represents a server. |
||
| 6 | */ |
||
| 7 | class Server |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | const PROTOCOL_WILDCARD = 'wildcard'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | const PROTOCOL_MARKER = 'marker'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | const PROTOCOL_DYNAMIC = 'dynamic'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | const PROTOCOL_HTTP = 'http'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | const PROTOCOL_HTTPS = 'https'; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | private $domain; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | private $protocol; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | private $identifier; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | private $protocolMarker; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param string $domain |
||
| 56 | */ |
||
| 57 | 6 | public function setDomain($domain) |
|
| 58 | { |
||
| 59 | 6 | $this->domain = $domain; |
|
| 60 | 6 | } |
|
| 61 | |||
| 62 | /** |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 2 | public function getDomain() |
|
| 66 | { |
||
| 67 | 2 | return $this->domain; |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param string $identifier |
||
| 72 | */ |
||
| 73 | 4 | public function setIdentifier($identifier) |
|
| 74 | { |
||
| 75 | 4 | $this->identifier = $identifier; |
|
| 76 | 4 | } |
|
| 77 | |||
| 78 | /** |
||
| 79 | * @return string |
||
| 80 | */ |
||
| 81 | 4 | public function getIdentifier() |
|
| 82 | { |
||
| 83 | 4 | return $this->identifier; |
|
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @param string $protocol |
||
| 88 | */ |
||
| 89 | 6 | public function setProtocol($protocol) |
|
| 90 | { |
||
| 91 | 6 | if (false === in_array($protocol, [self::PROTOCOL_WILDCARD, self::PROTOCOL_MARKER, self::PROTOCOL_HTTP, self::PROTOCOL_HTTPS, self::PROTOCOL_DYNAMIC])) { |
|
| 92 | 1 | return; |
|
| 93 | } |
||
| 94 | 6 | $this->protocol = $protocol; |
|
| 95 | 6 | } |
|
| 96 | |||
| 97 | /** |
||
| 98 | * @return string |
||
| 99 | */ |
||
| 100 | 2 | public function getProtocol() |
|
| 101 | { |
||
| 102 | 2 | return $this->protocol; |
|
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @param string $protocolMarker |
||
| 107 | */ |
||
| 108 | 2 | public function setProtocolMarker($protocolMarker) |
|
| 109 | { |
||
| 110 | 2 | $this->protocolMarker = $protocolMarker; |
|
| 111 | 2 | } |
|
| 112 | |||
| 113 | /** |
||
| 114 | * @return string |
||
| 115 | */ |
||
| 116 | 4 | public function getUri() |
|
| 117 | { |
||
| 118 | 4 | return $this->getProtocolPrefix() . $this->domain . '/'; |
|
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @return string |
||
| 123 | */ |
||
| 124 | 4 | private function getProtocolPrefix() |
|
| 125 | { |
||
| 126 | 4 | $protocolPrefix = ''; |
|
| 127 | 4 | $protocol = $this->protocol; |
|
| 128 | 4 | if ($protocol === self::PROTOCOL_DYNAMIC) { |
|
| 129 | $protocol = $this->getRequestProtocol(); |
||
| 130 | } |
||
| 131 | switch ($protocol) { |
||
| 132 | 4 | case self::PROTOCOL_MARKER : |
|
| 133 | 1 | $protocolPrefix = $this->protocolMarker; |
|
| 134 | 1 | break; |
|
| 135 | 3 | case self::PROTOCOL_WILDCARD : |
|
| 136 | 1 | $protocolPrefix = '//'; |
|
| 137 | 1 | break; |
|
| 138 | 2 | case self::PROTOCOL_HTTP : |
|
| 139 | 1 | $protocolPrefix = 'http://'; |
|
| 140 | 1 | break; |
|
| 141 | 1 | case self::PROTOCOL_HTTPS : |
|
| 142 | 1 | $protocolPrefix = 'https://';; |
|
| 143 | 1 | break; |
|
| 144 | } |
||
| 145 | 4 | return $protocolPrefix; |
|
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @return string |
||
| 150 | */ |
||
| 151 | protected function getRequestProtocol() |
||
| 152 | { |
||
| 153 | if (strlen($_SERVER['HTTPS']) > 0 || strtolower($_SERVER['HTTPS']) !== 'off') { |
||
| 154 | return \Aoe\Asdis\Domain\Model\Server::PROTOCOL_HTTPS; |
||
| 155 | } |
||
| 156 | return T\Aoe\Asdis\Domain\Model\Server::PROTOCOL_HTTP; |
||
|
0 ignored issues
–
show
|
|||
| 157 | } |
||
| 158 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths