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