Input::getCurrentUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Scheduler\Web\Radar\Input;
4
5
use Psr\Http\Message\ServerRequestInterface as Request;
6
use Scheduler\Domain\Model\User\Authenticator;
7
8
class Input
9
{
10
    private $authenticator;
11
12
    public function __construct(Authenticator $authenticator)
13
    {
14
        $this->authenticator = $authenticator;
15
    }
16
17
    public function __invoke(Request $request)
18
    {
19
        return [$this->getCurrentUser($request)];
20
    }
21
22
    protected function getCurrentUser(Request $request)
23
    {
24
        $token = $request->getHeaderLine("x-access-token");
25
26
        return $this->authenticator->authenticate($token);
27
    }
28
}
29