PartiallyLoggedIn   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 9
c 1
b 0
f 0
dl 0
loc 62
ccs 14
cts 14
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthId() 0 3 1
A verifyPassword() 0 3 1
A getUser() 0 3 1
A getAuthRole() 0 3 1
A __construct() 0 3 1
A requiresMfa() 0 3 1
A getAuthChecksum() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Auth\User;
6
7
use Jasny\Auth\ContextInterface;
8
use Jasny\Auth\UserInterface;
9
10
/**
11
 * Wrapper for user that is partially logged in.
12
 */
13
final class PartiallyLoggedIn implements UserInterface
14
{
15
    protected UserInterface $user;
16
17
    /**
18
     * Class constructor.
19
     *
20
     * @param UserInterface $user
21
     */
22 6
    public function __construct(UserInterface $user)
23
    {
24 6
        $this->user = $user;
25
    }
26
27
    /**
28
     * Get wrapper user.
29
     *
30
     * @return UserInterface
31
     */
32 1
    public function getUser(): UserInterface
33
    {
34 1
        return $this->user;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 1
    public function getAuthId(): string
41
    {
42 1
        return '#partial:' . $this->user->getAuthId();
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 1
    public function verifyPassword(string $password): bool
49
    {
50 1
        return $this->user->verifyPassword($password);
51
    }
52
53
    /**
54
     * @inheritDoc
55
     */
56 1
    public function getAuthChecksum(): string
57
    {
58 1
        return $this->user->getAuthChecksum();
59
    }
60
61
    /**
62
     * @inheritDoc
63
     */
64 1
    public function getAuthRole(?ContextInterface $context = null): int|array|string
65
    {
66 1
        return $this->user->getAuthRole($context);
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72 1
    public function requiresMfa(): bool
73
    {
74 1
        return true;
75
    }
76
}
77