| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace Symfony\Component\Console\Exception; |
| 13 |
|
| 14 |
/** |
| 15 |
* @author Jérôme Tamarelle <[email protected]> |
| 16 |
*/ |
| 17 |
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface |
| 18 |
{ |
| 19 |
/** |
| 20 |
* @internal |
| 21 |
*/ |
| 22 |
public static function fromEnumValue(string $name, string $value, array|\Closure $suggestedValues): self |
| 23 |
{ |
| 24 |
$error = \sprintf('The value "%s" is not valid for the "%s" argument.', $value, $name); |
| 25 |
|
| 26 |
if (\is_array($suggestedValues)) { |
| 27 |
$error .= \sprintf(' Supported values are "%s".', implode('", "', $suggestedValues)); |
| 28 |
} |
| 29 |
|
| 30 |
return new self($error); |
| 31 |
} |
| 32 |
} |