Total Complexity | 5 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Result implements Response |
||
9 | { |
||
10 | private const SUCCESS_KEY = 'success'; |
||
11 | |||
12 | /** @var array */ |
||
13 | private $payload; |
||
14 | |||
15 | private function __construct(array $data) |
||
16 | { |
||
17 | $this->payload = $data; |
||
18 | } |
||
19 | |||
20 | public static function ok(Board $board): self |
||
21 | { |
||
22 | return new self( |
||
23 | [ |
||
24 | self::SUCCESS_KEY => true, |
||
25 | 'board_uuid' => $board->getUuid()->getValue() |
||
26 | ] |
||
27 | ); |
||
28 | } |
||
29 | |||
30 | public static function fail(string $reason): self |
||
31 | { |
||
32 | return new self( |
||
33 | [ |
||
34 | self::SUCCESS_KEY => false, |
||
35 | 'error' => $reason |
||
36 | ] |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | public function isSuccess(): bool |
||
43 | } |
||
44 | |||
45 | public function getPayload(): array |
||
46 | { |
||
50 |