InvalidArgumentException.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /*
  3. * This file is part of the php-code-coverage package.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\CodeCoverage;
  11. final class InvalidArgumentException extends \InvalidArgumentException implements Exception
  12. {
  13. /**
  14. * @param int $argument
  15. * @param string $type
  16. * @param null|mixed $value
  17. *
  18. * @return InvalidArgumentException
  19. */
  20. public static function create($argument, $type, $value = null): self
  21. {
  22. $stack = \debug_backtrace(0);
  23. return new self(
  24. \sprintf(
  25. 'Argument #%d%sof %s::%s() must be a %s',
  26. $argument,
  27. $value !== null ? ' (' . \gettype($value) . '#' . $value . ')' : ' (No Value) ',
  28. $stack[1]['class'],
  29. $stack[1]['function'],
  30. $type
  31. )
  32. );
  33. }
  34. }