AuthRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 33
ccs 15
cts 15
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 3 1
A getMethod() 0 3 1
A getBody() 0 6 1
A getResponseHandler() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace Nighten\ApiClient\Request;
4
5
use Nighten\ApiClient\Response\Auth\AuthResponseHandler;
6
use Nighten\ApiClient\Response\ResponseHandlerInterface;
7
use Nighten\ApiClient\ResponseHandlerAwareInterface;
8
9
class AuthRequest implements RequestInterface, ResponseHandlerAwareInterface
10
{
11
    private string $login;
12
13
    private string $password;
14
15 1
    public function __construct(string $login, string $password)
16
    {
17 1
        $this->login = $login;
18 1
        $this->password = $password;
19 1
    }
20
21 1
    public function getPath(): string
22
    {
23 1
        return '/login/';
24
    }
25
26 1
    public function getBody(): string
27
    {
28 1
        return json_encode([
29 1
            'login' => $this->login,
30 1
            'password' => $this->password
31 1
        ], JSON_THROW_ON_ERROR);
32
    }
33
34 1
    public function getMethod(): string
35
    {
36 1
        return 'POST';
37
    }
38
39 1
    public function getResponseHandler(): ResponseHandlerInterface
40
    {
41 1
        return new AuthResponseHandler();
42
    }
43
}
44