IpToUserMapper::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Kaliop\IdentityManagementBundle\Security\Helper;
4
5
use Kaliop\IdentityManagementBundle\Security\Interfaces\IpToUserMapper as MapperInterface;
6
7
/**
8
 * A very, very simplistic implementation of the interface
9
 */
10
class IpToUserMapper implements MapperInterface
11
{
12
    protected $ipList = array();
13
14
    /**
15
     * @param array $ipList key: ip, value: user id
16
     */
17
    public function __construct(array $ipList)
18
    {
19
        $this->ipList = $ipList;
20
    }
21
22
    public function getInternalUser($ip)
23
    {
24
        return isset($this->ipList[$ip]) ? $this->ipList[$ip] : false;
25
    }
26
}
27