RandomNumber.php 802 B

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