CommandNotFoundException.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Console\Exception;
  11. /**
  12. * Represents an incorrect command name typed in the console.
  13. *
  14. * @author Jérôme Tamarelle <jerome@tamarelle.net>
  15. */
  16. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  17. {
  18. private $alternatives;
  19. /**
  20. * @param string $message Exception message to throw
  21. * @param array $alternatives List of similar defined names
  22. * @param int $code Exception code
  23. * @param \Throwable $previous Previous exception used for the exception chaining
  24. */
  25. public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null)
  26. {
  27. parent::__construct($message, $code, $previous);
  28. $this->alternatives = $alternatives;
  29. }
  30. /**
  31. * @return array A list of similar defined names
  32. */
  33. public function getAlternatives()
  34. {
  35. return $this->alternatives;
  36. }
  37. }