| @@ 70-86 (lines=17) @@ | ||
| 67 | * @param $host |
|
| 68 | * @return string |
|
| 69 | */ |
|
| 70 | public function setHost($host) |
|
| 71 | {
|
|
| 72 | if (!is_string($host)) {
|
|
| 73 | return false; |
|
| 74 | } |
|
| 75 | ||
| 76 | $parsed_host = parse_url($host, PHP_URL_HOST); |
|
| 77 | ||
| 78 | if (is_null($parsed_host)) {
|
|
| 79 | $parsed_host = $host; |
|
| 80 | } else {
|
|
| 81 | $scheme = parse_url($host, PHP_URL_SCHEME); |
|
| 82 | $this->setSSL($scheme === 'https'); |
|
| 83 | } |
|
| 84 | ||
| 85 | return $this->set('host', $parsed_host);
|
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * @param $port |
|
| @@ 128-143 (lines=16) @@ | ||
| 125 | * @param $host |
|
| 126 | * @return string |
|
| 127 | */ |
|
| 128 | public function setServerNameFromHost($host) |
|
| 129 | {
|
|
| 130 | if (!is_string($host)) {
|
|
| 131 | return false; |
|
| 132 | } |
|
| 133 | ||
| 134 | $parsed_host = parse_url($host, PHP_URL_HOST); |
|
| 135 | ||
| 136 | if (is_null($parsed_host)) {
|
|
| 137 | $serverName = $host; |
|
| 138 | } else {
|
|
| 139 | $serverName = preg_replace('/^www\./', '', $parsed_host);
|
|
| 140 | } |
|
| 141 | ||
| 142 | return $this->set('serverName', $serverName);
|
|
| 143 | } |
|
| 144 | ||
| 145 | /** |
|
| 146 | * @param $bool |
|