Total Complexity | 6 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 61.53% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | class ScenarioState |
||
22 | { |
||
23 | const INITIAL_SCENARIO = 'Scenario.START'; |
||
24 | |||
25 | /** @var string * */ |
||
26 | private $state; |
||
27 | |||
28 | 6 | public function __construct(string $state) |
|
29 | { |
||
30 | 6 | $this->ensureNotEmpty($state); |
|
31 | 6 | $this->state = $state; |
|
32 | 6 | } |
|
33 | |||
34 | public static function createInitial() |
||
35 | { |
||
36 | return new self(self::INITIAL_SCENARIO); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return string |
||
41 | */ |
||
42 | 6 | public function asString() |
|
43 | { |
||
44 | 6 | return $this->state; |
|
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param ScenarioState $other |
||
49 | * |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function equals($other) |
||
53 | { |
||
54 | return $other->asString() === $this->asString(); |
||
55 | } |
||
56 | |||
57 | 6 | private function ensureNotEmpty($state) |
|
61 | } |
||
62 | 6 | } |
|
63 | } |
||
64 |