Passed
Push — master ( 35eebd...7b8a1a )
by Roman
16:45
created

FailedApiResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A body() 0 5 1
A __construct() 0 4 1
A status() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Game\Features\Answers\Response;
6
7
use App\Game\Features\Answers\Response\Error\ErrorCriteria;
8
9
/**
10
 * @psalm-immutable
11
 */
12
final class FailedApiResponse implements ResponseInterface
13
{
14
    private int $status;
15
    private ErrorCriteria $error;
16
17
    public function __construct(ErrorCriteria $error, int $status = HttpStatusCode::HTTP_ERROR)
18
    {
19
        $this->status = $status;
20
        $this->error = $error;
21
    }
22
23
    /**
24
     * @psalm-suppress ImpureMethodCall
25
     */
26
    public function body(): array
27
    {
28
        return [
29
            'success' => false,
30
            'error' => $this->error->jsonSerialize(),
31
        ];
32
    }
33
34
    public function status(): int
35
    {
36
        return $this->status;
37
    }
38
}
39