ForceLogin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 41
ccs 3
cts 12
cp 0.25
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getUser() 0 4 1
A setUser() 0 5 1
A authenticate() 0 7 2
1
<?php
2
3
namespace JwPersistentUser\Authentication\Adapter;
4
5
use ZfcUser\Entity\UserInterface;
6
7
use Zend\Authentication\Result;
8
use Zend\Authentication\Adapter\AdapterInterface;
9
10
class ForceLogin implements AdapterInterface
11
{
12
    /**
13
     * @var UserInterface|int
14
     */
15
    protected $user;
16
17
    /**
18
     * @param UserInterface|int $user
19
     */
20 1
    public function __construct($user)
21
    {
22 1
        $this->user = $user;
23 1
    }
24
25
    public function authenticate()
26
    {
27
        return new Result(
28
            Result::SUCCESS,
29
            is_int($this->getUser()) ? $this->getUser() : $this->getUser()->getId()
30
        );
31
    }
32
33
    /**
34
     * @return UserInterface|int
35
     */
36
    public function getUser()
37
    {
38
        return $this->user;
39
    }
40
41
    /**
42
     * @param UserInterface|int $user
43
     * @return $this
44
     */
45
    public function setUser($user)
46
    {
47
        $this->user = $user;
48
        return $this;
49
    }
50
}
51