AMethods   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isAuthorized() 0 3 1
A getLoggedUser() 0 3 1
A __construct() 0 4 1
A getNextMethod() 0 3 1
1
<?php
2
3
namespace kalanis\kw_auth\Methods;
4
5
6
use kalanis\kw_accounts\AccountsException;
7
use kalanis\kw_accounts\Interfaces\IAuth;
8
use kalanis\kw_accounts\Interfaces\IUser;
9
use kalanis\kw_auth\AuthException;
10
11
12
/**.
13
 * Class AMethods
14
 * @package kalanis\kw_auth\AuthMethods
15
 * Chain of responsibility for authentication
16
 */
17
abstract class AMethods
18
{
19
    protected ?IAuth $authenticator = null;
20
    protected ?AMethods $nextOne = null;
21
    protected ?IUser $loggedUser = null;
22
23 25
    public function __construct(?IAuth $authenticator, ?AMethods $nextOne)
24
    {
25 25
        $this->authenticator = $authenticator;
26 25
        $this->nextOne = $nextOne;
27 25
    }
28
29
    /**
30
     * @param \ArrayAccess<string, string|int|float> $credentials
31
     * @throws AccountsException
32
     * @throws AuthException
33
     */
34
    abstract public function process(\ArrayAccess $credentials): void;
35
36
    abstract public function remove(): void;
37
38 20
    public function isAuthorized(): bool
39
    {
40 20
        return !empty($this->loggedUser);
41
    }
42
43 3
    public function getLoggedUser(): ?IUser
44
    {
45 3
        return $this->loggedUser;
46
    }
47
48 2
    public function getNextMethod(): ?AMethods
49
    {
50 2
        return $this->nextOne;
51
    }
52
}
53