Total Complexity | 6 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Coverage | 70% |
Changes | 0 |
1 | <?php |
||
14 | 1 | abstract class BaseResponse implements IResponse |
|
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var iterable<string|int, mixed>|stdClass |
||
19 | */ |
||
20 | protected iterable|stdClass $data = []; |
||
21 | |||
22 | private bool $prettyPrint = true; |
||
23 | |||
24 | 1 | public function __construct( |
|
25 | protected IMapper $mapper, |
||
26 | protected readonly string|null $contentType = null, |
||
27 | ) |
||
28 | { |
||
29 | 1 | } |
|
30 | |||
31 | /** |
||
32 | * Is pretty print enabled |
||
33 | */ |
||
34 | public function isPrettyPrint(): bool |
||
35 | { |
||
36 | 1 | return $this->prettyPrint; |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Set pretty print |
||
41 | */ |
||
42 | public function setPrettyPrint(bool $pretty): self |
||
43 | { |
||
44 | 1 | $this->prettyPrint = $pretty; |
|
45 | 1 | return $this; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Get response content type |
||
50 | */ |
||
51 | public function getContentType(): ?string |
||
52 | { |
||
53 | 1 | return $this->contentType; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Get response data |
||
58 | * @return iterable<string|int, mixed>|stdClass|string |
||
59 | */ |
||
60 | public function getData(): iterable|stdClass|string |
||
61 | { |
||
62 | return $this->data; |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Set mapper |
||
67 | */ |
||
68 | public function setMapper(IMapper $mapper): self |
||
72 | } |
||
73 | } |
||
74 |