CaptureIpTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 16
c 1
b 0
f 1
dl 0
loc 23
rs 10
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B getClientIp() 0 19 7
1
<?php
2
3
namespace App\Traits;
4
5
class CaptureIpTrait
6
{
7
    // private $ipAddress = null;
8
9
    public function getClientIp()
10
    {
11
        if (getenv('HTTP_CLIENT_IP')) {
12
            $ipAddress = getenv('HTTP_CLIENT_IP');
13
        } elseif (getenv('HTTP_X_FORWARDED_FOR')) {
14
            $ipAddress = getenv('HTTP_X_FORWARDED_FOR');
15
        } elseif (getenv('HTTP_X_FORWARDED')) {
16
            $ipAddress = getenv('HTTP_X_FORWARDED');
17
        } elseif (getenv('HTTP_FORWARDED_FOR')) {
18
            $ipAddress = getenv('HTTP_FORWARDED_FOR');
19
        } elseif (getenv('HTTP_FORWARDED')) {
20
            $ipAddress = getenv('HTTP_FORWARDED');
21
        } elseif (getenv('REMOTE_ADDR')) {
22
            $ipAddress = getenv('REMOTE_ADDR');
23
        } else {
24
            $ipAddress = 'UNKNOWN';
25
        }
26
27
        return $ipAddress;
28
    }
29
}
30