Conditions | 7 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | private function getIpByServerGlobalArray(): IpAddress |
||
16 | { |
||
17 | $ipAddressString = ''; |
||
18 | |||
19 | if (!empty($_SERVER['REMOTE_ADDR']) |
||
20 | && $this->isIpValid($remoteAddrIpAddressString = trim($_SERVER['REMOTE_ADDR'])) |
||
21 | ) { |
||
22 | $ipAddressString = $remoteAddrIpAddressString; |
||
23 | } elseif (!empty($_SERVER['HTTP_CLIENT_IP']) |
||
24 | && $this->isIpValid($httpClientIpAddressString = trim($_SERVER['HTTP_CLIENT_IP'])) |
||
25 | ) { |
||
26 | $ipAddressString = $httpClientIpAddressString; |
||
27 | } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']) |
||
28 | && $this->isIpValid($httpForwardedIpAddressString = trim($_SERVER['HTTP_X_FORWARDED_FOR'])) |
||
29 | ) { |
||
30 | $ipAddressString = $httpForwardedIpAddressString; |
||
31 | } |
||
32 | |||
33 | return new IpAddress($ipAddressString); |
||
34 | } |
||
41 |