| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class LightSwitch implements AggregateRootWithSnapshotting |
||
| 13 | { |
||
| 14 | use AggregateRootBehaviour; |
||
| 15 | use SnapshottingBehaviour; |
||
| 16 | |||
| 17 | public const OFF = false; |
||
| 18 | public const ON = true; |
||
| 19 | |||
| 20 | private bool $state = self::OFF; |
||
| 21 | |||
| 22 | private function createSnapshotState(): bool |
||
|
|
|||
| 23 | { |
||
| 24 | return $this->state; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function state(): bool |
||
| 28 | 1 | { |
|
| 29 | return $this->state; |
||
| 30 | 1 | } |
|
| 31 | |||
| 32 | public function turnOn(): void |
||
| 33 | 1 | { |
|
| 34 | if (self::OFF == $this->state) { |
||
| 35 | 1 | $this->recordThat(LightSwitchWasFlipped::on()); |
|
| 36 | } |
||
| 37 | } |
||
| 38 | 3 | ||
| 39 | public function turnOff(): void |
||
| 40 | 3 | { |
|
| 41 | 2 | if (self::ON == $this->state) { |
|
| 42 | $this->recordThat(LightSwitchWasFlipped::off()); |
||
| 43 | 3 | } |
|
| 44 | } |
||
| 45 | 3 | ||
| 46 | protected function applyLightSwitchWasFlipped(LightSwitchWasFlipped $event): void |
||
| 49 | } |
||
| 50 | 3 | ||
| 51 | /** |
||
| 52 | 4 | * @param bool $state |
|
| 53 | */ |
||
| 54 | 4 | protected static function reconstituteFromSnapshotState(AggregateRootId $id, $state): AggregateRootWithSnapshotting |
|
| 60 | 1 | } |
|
| 61 | } |
||
| 62 |
This check looks for private methods that have been defined, but are not used inside the class.