@@ -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 = ''; |
| 29 | - $ipKeys =['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 | + $ipKeys = ['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 ($ipKeys as $key): |
| 32 | 32 | if (array_key_exists($key, $_SERVER) && !empty($_SERVER[$key])): |
| 33 | 33 | $ipAddress = $_SERVER[$key]; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | break; |
| 38 | 38 | endif; |
| 39 | 39 | endforeach; |
| 40 | - return $ipAddress?:'0.0.0.0'; |
|
| 40 | + return $ipAddress ?: '0.0.0.0'; |
|
| 41 | 41 | } |
| 42 | 42 | /** |
| 43 | 43 | * If IPV6, Returns the IP in it's fullest format. |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | { |
| 76 | 76 | $ipAddress = $this->expandAddress($ipAddress); |
| 77 | 77 | if (strpos($ipAddress, ':') !== false): |
| 78 | - $bin = inet_pton($ipAddress) ; |
|
| 79 | - $ints = unpack('J2', $bin) ; |
|
| 80 | - return $ints[1] ; |
|
| 78 | + $bin = inet_pton($ipAddress); |
|
| 79 | + $ints = unpack('J2', $bin); |
|
| 80 | + return $ints[1]; |
|
| 81 | 81 | endif; |
| 82 | 82 | return ip2long($ipAddress); |
| 83 | 83 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | try |
| 112 | 112 | { |
| 113 | 113 | $ipAddress = $this->expandAddress($ipAddress); |
| 114 | - if (strpos($ipAddress, ':') !== false) {return 6;} |
|
| 114 | + if (strpos($ipAddress, ':') !== false) {return 6; } |
|
| 115 | 115 | return 4; |
| 116 | 116 | } catch (\Throwable $th) { |
| 117 | 117 | trigger_error($th->getMessage(), E_USER_ERROR); |