Created
December 8, 2021 17:29
-
-
Save dgafka/d054c4e62a63e166ab05fe90f2e40e48 to your computer and use it in GitHub Desktop.
Event Sourcing PHP 03
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product | |
{ | |
private int $productId; | |
private float $price; | |
public function changePrice(float $price): array | |
{ | |
return [new PriceWasChanged($this->productId, $price)]; | |
} | |
public function onPriceWasChanged(PriceWasChanged $event): void | |
{ | |
$this->price = $event->getPrice(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment