TooManyRecipients.php 994 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * Copyright (C) 2013 Mailgun
  5. *
  6. * This software may be modified and distributed under the terms
  7. * of the MIT license. See the LICENSE file for details.
  8. */
  9. namespace Mailgun\Message\Exceptions;
  10. use Mailgun\Exception;
  11. use Mailgun\Message\MessageBuilder;
  12. class TooManyRecipients extends LimitExceeded implements Exception
  13. {
  14. /**
  15. * @param string $field
  16. * @param int $limit
  17. * @return LimitExceeded|self
  18. */
  19. public static function create(string $field, int $limit = MessageBuilder::RECIPIENT_COUNT_LIMIT)
  20. {
  21. return new self(sprintf('You\'ve exceeded the maximum recipient count (%s) for filed "%s".', $limit, $field));
  22. }
  23. /**
  24. * @param int $limit
  25. * @return self
  26. */
  27. public static function whenAutoSendDisabled(int $limit = MessageBuilder::RECIPIENT_COUNT_LIMIT)
  28. {
  29. return new self(sprintf('You\'ve exceeded the maximum recipient count (%s) with autosend disabled.', $limit));
  30. }
  31. }