InMemoryAuthenticator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A authenticate() 0 12 2
1
<?php
2
3
namespace Scheduler\Domain\Model\User;
4
5
class InMemoryAuthenticator implements Authenticator
6
{
7
    private $userMapper;
8
9
    private $tokenMap;
10
11
    public function __construct(UserMapper $userMapper, array $tokenMap)
12
    {
13
        $this->userMapper = $userMapper;
14
        $this->tokenMap = $tokenMap;
15
    }
16
17
    public function authenticate($token)
18
    {
19
        if (! array_key_exists($token, $this->tokenMap)) {
20
            return new NullUser();
21
        }
22
23
        $id = $this->tokenMap[$token];
24
        $user = $this->userMapper->find($id);
25
        $user->authenticate();
26
27
        return $user;
28
    }
29
}
30