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

SuccessApiResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 22
ccs 5
cts 9
cp 0.5556
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

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