|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * This file is part of prooph/proophessor. |
| 4 | + * (c) 2014-2015 prooph software GmbH <[email protected]> |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + * |
| 9 | + * Date: 2/16/16 |
| 10 | + */ |
| 11 | +namespace Prooph\ProophessorDo\Model\Todo\Event; |
| 12 | + |
| 13 | +use Prooph\EventSourcing\AggregateChanged; |
| 14 | +use Prooph\ProophessorDo\Model\Todo\TodoId; |
| 15 | +use Prooph\ProophessorDo\Model\Todo\TodoStatus; |
| 16 | + |
| 17 | +/** |
| 18 | + * Class TodoWasReopened |
| 19 | + * |
| 20 | + * @package Prooph\ProophessorDo\Model\Todo\Event |
| 21 | + * @author Bas Kamer <[email protected]> |
| 22 | + */ |
| 23 | +final class TodoWasReopened extends AggregateChanged |
| 24 | +{ |
| 25 | + private $todoId; |
| 26 | + |
| 27 | + private $status; |
| 28 | + |
| 29 | + /** |
| 30 | + * @param TodoId $todoId |
| 31 | + * @param TodoStatus $status |
| 32 | + * @return TodoWasMarkedAsDone |
| 33 | + */ |
| 34 | + public static function withStatus(TodoId $todoId, TodoStatus $status) |
| 35 | + { |
| 36 | + $event = self::occur($todoId->toString(), [ |
| 37 | + 'status' => $status->toString() |
| 38 | + ]); |
| 39 | + |
| 40 | + $event->todoId = $todoId; |
| 41 | + $event->status = $status; |
| 42 | + |
| 43 | + return $event; |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @return TodoId |
| 48 | + */ |
| 49 | + public function todoId() |
| 50 | + { |
| 51 | + if (null === $this->todoId) { |
| 52 | + $this->todoId = TodoId::fromString($this->aggregateId()); |
| 53 | + } |
| 54 | + return $this->todoId; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @return TodoStatus |
| 59 | + */ |
| 60 | + public function status() |
| 61 | + { |
| 62 | + if (null === $this->status) { |
| 63 | + $this->status = TodoStatus::fromString($this->payload['status']); |
| 64 | + } |
| 65 | + return $this->status; |
| 66 | + } |
| 67 | +} |
0 commit comments