Passed
Push — master ( 1457de...9c6417 )
by Tomasz
02:07
created

Result::isSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Aggrego\Domain\Api\Command\TransformBoard;
4
5
use Aggrego\Domain\Board\Board;
6
7
class Result
8
{
9
    private const SUCCESS_KEY = 'success';
10
11
    /** @var array */
12
    private $data;
13
14
    private function __construct(array $data)
15
    {
16
        $this->data = $data;
17
    }
18
19
    public static function ok(Board $board): self
20
    {
21
        return new self(
22
            [
23
                self::SUCCESS_KEY => true,
24
                'board_uuid' => $board->getUuid()->getValue()
25
            ]
26
        );
27
    }
28
29
    public static function fail(string $reason): self
30
    {
31
        return new self(
32
            [
33
                self::SUCCESS_KEY => false,
34
                'error' => $reason
35
            ]
36
        );
37
    }
38
39
    public function isSuccess(): bool
40
    {
41
        return $this->data[self::SUCCESS_KEY];
42
    }
43
44
    public function getData(): array
45
    {
46
        return $this->data;
47
    }
48
}
49