AuthenticationContext::authenticate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace kalanis\Restful\Security;
4
5
6
use kalanis\Restful\Http\IInput;
7
use kalanis\Restful\Security\Process\AuthenticationProcess;
8
9
10
/**
11
 * AuthenticationContext determines which authentication process should use
12
 * @package kalanis\Restful\Security
13
 */
14
class AuthenticationContext
15
{
16
17
    private AuthenticationProcess $process;
18
19
    /**
20
     * Set authentication process to use
21
     */
22
    public function setAuthProcess(AuthenticationProcess $process): static
23
    {
24
        $this->process = $process;
25
        return $this;
26
    }
27
28
    /**
29
     * Authenticate request with authentication process strategy
30
     * @param IInput $input
31
     * @throws Exceptions\RequestTimeoutException
32
     * @throws Exceptions\AuthenticationException
33
     * @return bool
34
     */
35
    public function authenticate(IInput $input): bool
36
    {
37
        return $this->process->authenticate($input);
38
    }
39
}
40