UserInfoService::getUserIP()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Lii\Service;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
/**
9
 * A service class that is injected with di.
10
 */
11
class UserInfoService implements ContainerInjectableInterface
12
{
13
    use ContainerInjectableTrait;
14
15
//     public function useService() : string
16
//     {
17
//         return "DI contains " . count($this->di->getServices()) . " services.";
18
//     }
19
20 2
    public function getUserIP() : string
21
    {
22 2
        $request = $this->di->get("request");
23 2
        $userIP = $request->getServer("HTTP_X_FORWARDED_FOR", "x.x.x.x");
24
25 2
        return $userIP;
26
    }
27
}
28