Lines
0.00%
0 / 2
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| StateUpdate | 0.00% | 0 / 2 | 0.00% | 0 / 2 | 6 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| toStateChange | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Support\State; | |
| 6 | ||
| 7 | use Stewart\Contracts\Entity\EntityId; | |
| 8 | use Stewart\Contracts\State\EntityState; | |
| 9 | use Stewart\Contracts\State\EventContext; | |
| 10 | use Stewart\Contracts\State\StateChange; | |
| 11 | use Stewart\Contracts\State\StateChangeOrigin; | |
| 12 | use Stewart\Contracts\Time\Instant; | |
| 13 | ||
| 14 | /** @internal */ | |
| 15 | final readonly class StateUpdate | |
| 16 | { | |
| 17 | public function __construct( | |
| 18 | public EntityId $entityId, | |
| 19 | public ?EntityState $to, | |
| 20 | public ?Instant $firedAt = null, | |
| 21 | public ?EventContext $context = null, | |
| 22 | public StateChangeOrigin $origin = StateChangeOrigin::Live, | |
| 23 | ) {} | |
| 24 | ||
| 25 | public function toStateChange(?EntityState $from): StateChange | |
| 26 | { | |
| 27 | return new StateChange($this->entityId, $from, $this->to, $this->firedAt, $this->context, $this->origin); | |
| 28 | } | |
| 29 | } |