Test Failed
Push — master ( 85ca69...144c12 )
by Roman
15:41
created

SuccessApiResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10

3 Methods

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