@@ -7,13 +7,13 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @var string $ipAddress |
9 | 9 | **/ |
10 | - private $ipAddress=null; |
|
10 | + private $ipAddress = null; |
|
11 | 11 | /** |
12 | 12 | * Class constructor. |
13 | 13 | * |
14 | 14 | * @param string $ipAddress |
15 | 15 | */ |
16 | - public function __construct(string $ipAddress=null) |
|
16 | + public function __construct(string $ipAddress = null) |
|
17 | 17 | { |
18 | 18 | $ipAddress || $ipAddress = $this->getIPAddress(); |
19 | 19 | $this->validateAddress($ipAddress); |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | public function getIPAddress() |
27 | 27 | { |
28 | 28 | $ipAddress = null; |
29 | - $serverIPKeys =['HTTP_X_COMING_FROM', 'HTTP_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
30 | - 'HTTP_X_FORWARDED', 'HTTP_VIA', 'HTTP_CLIENT_IP','HTTP_X_FORWARDED_FOR','REMOTE_ADDR']; |
|
29 | + $serverIPKeys = ['HTTP_X_COMING_FROM', 'HTTP_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
30 | + 'HTTP_X_FORWARDED', 'HTTP_VIA', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR']; |
|
31 | 31 | foreach ($serverIPKeys as $IPKey): |
32 | 32 | if (array_key_exists($IPKey, $_SERVER)) { |
33 | 33 | if (!strlen($_SERVER[$IPKey])) { continue; } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $ipAddress = substr($ipAddress, 0, ($commaPos - 1)); |
41 | 41 | } |
42 | - return $ipAddress?:'0.0.0.0'; |
|
42 | + return $ipAddress ?: '0.0.0.0'; |
|
43 | 43 | } |
44 | 44 | /** |
45 | 45 | * If IPV6, Returns the IP in it's fullest format. |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | { |
78 | 78 | $ipAddress = $this->expandAddress($ipAddress); |
79 | 79 | if (strpos($ipAddress, ':') !== false): |
80 | - $bin = inet_pton($ipAddress) ; |
|
81 | - $ints = unpack('J2', $bin) ; |
|
82 | - return $ints[1] ; |
|
80 | + $bin = inet_pton($ipAddress); |
|
81 | + $ints = unpack('J2', $bin); |
|
82 | + return $ints[1]; |
|
83 | 83 | endif; |
84 | 84 | return ip2long($ipAddress); |
85 | 85 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | try |
114 | 114 | { |
115 | 115 | $ipAddress = $this->expandAddress($ipAddress); |
116 | - if (strpos($ipAddress, ':') !== false) {return 6;} |
|
116 | + if (strpos($ipAddress, ':') !== false) {return 6; } |
|
117 | 117 | return 4; |
118 | 118 | } catch (\Throwable $th) { |
119 | 119 | trigger_error($th->getMessage(), E_USER_ERROR); |