CurrentIp::findIp()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
nc 3
nop 0
dl 0
loc 12
c 1
b 0
f 1
cc 3
ccs 5
cts 7
cp 0.7143
crap 3.2098
rs 10
1
<?php
2
3
namespace Anax\Models;
4
5
class CurrentIp
6
{
7
    /**
8
     * class to find current users ip address if available
9
     */
10 2
    public function findIp()
11
    {
12 2
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
13
            $userIP = [$_SERVER['HTTP_X_FORWARDED_FOR']];
14 2
        } elseif (isset($_SERVER['REMOTE_ADDR'])) {
15
            $userIP = [$_SERVER['REMOTE_ADDR']];
16
        } else {
17
            // only for testing
18 2
            $userIP = ["127.0.0.1"];
19
        }
20
21 2
        return $userIP;
22
    }
23
}
24