SearchLengthException.class.php 911 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Custom exception when search length is too short
  4. *
  5. * @author Christopher Han <xiphux@gmail.com>
  6. * @copyright Copyright (c) 2012 Christopher Han
  7. * @package GitPHP
  8. * @subpackage Exception
  9. */
  10. class GitPHP_SearchLengthException extends GitPHP_MessageException
  11. {
  12. /**
  13. * Minimum length
  14. *
  15. * @var int
  16. */
  17. public $MinimumLength;
  18. /**
  19. * Constructor
  20. *
  21. * @param int $minLength minimum search length
  22. * @param string $message message
  23. * @param int $code exception code
  24. */
  25. public function __construct($minLength, $message = '', $code = 0)
  26. {
  27. $this->MinimumLength = $minLength;
  28. if (empty($message)) {
  29. if ($minLength == 1)
  30. $message = 'You must enter search text of at least %1$d character';
  31. else
  32. $message = 'You must enter search text of at least %1$d characters';
  33. $message = sprintf($message, $minLength);
  34. }
  35. parent::__construct($message, true, 200, $code);
  36. }
  37. }