RandomNumber.php 658 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Benchmark\Entities;
  3. use Hamlet\Database\Entity;
  4. use JsonSerializable;
  5. final class RandomNumber implements Entity, JsonSerializable
  6. {
  7. public function __construct(private int $id, private int $randomNumber) {}
  8. public function id(): int
  9. {
  10. return $this->id;
  11. }
  12. public function number(): int
  13. {
  14. return $this->randomNumber;
  15. }
  16. public function withNumber(int $number): self
  17. {
  18. return new self($this->id, $number);
  19. }
  20. public function jsonSerialize(): array
  21. {
  22. return [
  23. 'id' => $this->id,
  24. 'randomNumber' => $this->randomNumber
  25. ];
  26. }
  27. }