@@ -7,52 +7,52 @@ |
||
7 | 7 | */ |
8 | 8 | trait SchemeAttribute |
9 | 9 | { |
10 | - protected $host; |
|
11 | - protected $port; |
|
12 | - protected $scheme; |
|
10 | + protected $host; |
|
11 | + protected $port; |
|
12 | + protected $scheme; |
|
13 | 13 | |
14 | - public function getScheme() |
|
15 | - { |
|
16 | - $server = $this->getServer(); |
|
17 | - if (!isset($this->scheme)) { |
|
18 | - if (array_key_exists('HTTPS', $server) && strcasecmp($server['HTTPS'], 'off') != 0) { |
|
19 | - $scheme = 'https'; |
|
20 | - } elseif (array_key_exists('REQUEST_SCHEME', $server)) { |
|
21 | - $scheme = $server['REQUEST_SCHEME']; |
|
22 | - } else { |
|
23 | - $scheme = 'http'; |
|
24 | - } |
|
25 | - } |
|
26 | - return $this->scheme = $scheme; |
|
27 | - } |
|
14 | + public function getScheme() |
|
15 | + { |
|
16 | + $server = $this->getServer(); |
|
17 | + if (!isset($this->scheme)) { |
|
18 | + if (array_key_exists('HTTPS', $server) && strcasecmp($server['HTTPS'], 'off') != 0) { |
|
19 | + $scheme = 'https'; |
|
20 | + } elseif (array_key_exists('REQUEST_SCHEME', $server)) { |
|
21 | + $scheme = $server['REQUEST_SCHEME']; |
|
22 | + } else { |
|
23 | + $scheme = 'http'; |
|
24 | + } |
|
25 | + } |
|
26 | + return $this->scheme = $scheme; |
|
27 | + } |
|
28 | 28 | |
29 | - public function getHost() |
|
30 | - { |
|
31 | - if (isset($this->host)) { |
|
32 | - return $this->host; |
|
33 | - } |
|
34 | - return $this->host = $this->getServer()['HTTP_HOST'] ?? 'localhost'; |
|
35 | - } |
|
29 | + public function getHost() |
|
30 | + { |
|
31 | + if (isset($this->host)) { |
|
32 | + return $this->host; |
|
33 | + } |
|
34 | + return $this->host = $this->getServer()['HTTP_HOST'] ?? 'localhost'; |
|
35 | + } |
|
36 | 36 | |
37 | - public function getPort() |
|
38 | - { |
|
39 | - if (isset($this->port)) { |
|
40 | - return $this->port; |
|
41 | - } |
|
42 | - return $this->port = $this->getServer()['SERVER_PORT'] ?? 80; |
|
43 | - } |
|
37 | + public function getPort() |
|
38 | + { |
|
39 | + if (isset($this->port)) { |
|
40 | + return $this->port; |
|
41 | + } |
|
42 | + return $this->port = $this->getServer()['SERVER_PORT'] ?? 80; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * 获取服务器基础URI |
|
47 | - * |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getServerURI() |
|
51 | - { |
|
52 | - return $this->getScheme().'://'.$this->getHost(); |
|
53 | - } |
|
45 | + /** |
|
46 | + * 获取服务器基础URI |
|
47 | + * |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getServerURI() |
|
51 | + { |
|
52 | + return $this->getScheme().'://'.$this->getHost(); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * Get 服务器属性 |
57 | 57 | * |
58 | 58 | * @return array |