Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created December 8, 2021 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgafka/d054c4e62a63e166ab05fe90f2e40e48 to your computer and use it in GitHub Desktop.
Save dgafka/d054c4e62a63e166ab05fe90f2e40e48 to your computer and use it in GitHub Desktop.
Event Sourcing PHP 03
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