ForceLogin::authenticate()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 6
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