| Total Complexity | 5 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class Originator |
||
| 12 | { |
||
| 13 | /** @var State */ |
||
| 14 | private State $state; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Originator constructor. |
||
| 18 | * |
||
| 19 | * @param State $state |
||
| 20 | */ |
||
| 21 | public function __construct(State $state) |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param State $state |
||
| 28 | * @return $this |
||
| 29 | */ |
||
| 30 | public function changeState(State $state): Originator |
||
| 31 | { |
||
| 32 | $this->state = $state; |
||
| 33 | |||
| 34 | return $this; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @return Memento |
||
| 39 | */ |
||
| 40 | public function save(): Memento |
||
| 41 | { |
||
| 42 | return new Memento($this->state); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @return State |
||
| 47 | */ |
||
| 48 | public function state(): State |
||
| 49 | { |
||
| 50 | return $this->state; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param Memento $memento |
||
| 55 | * @return Memento |
||
| 56 | */ |
||
| 57 | public function undo(Memento $memento): Memento |
||
| 62 | } |
||
| 63 | } |
||
| 64 |