Passed
Push — master ( 1fb483...35eebd )
by Roman
04:31
created

FailedApiResponse::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Crossword\Features\Receiver\Response;
6
7
use App\Crossword\Features\Receiver\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