CaptureIpTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

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