MultipleItemsFoundException.php 876 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Collection;
  12. use RuntimeException;
  13. use Throwable;
  14. class MultipleItemsFoundException extends RuntimeException
  15. {
  16. /**
  17. * The number of items found.
  18. */
  19. public int $count;
  20. /**
  21. * Create a new exception instance.
  22. *
  23. * @param null|Throwable $previous
  24. */
  25. public function __construct(int $count, int $code = 0, $previous = null)
  26. {
  27. $this->count = $count;
  28. parent::__construct("{$count} items were found.", $code, $previous);
  29. }
  30. /**
  31. * Get the number of items found.
  32. */
  33. public function getCount(): int
  34. {
  35. return $this->count;
  36. }
  37. }