| 1 |
<?php |
| 2 |
/** |
| 3 |
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. |
| 4 |
* |
| 5 |
* @package PHPCSUtils |
| 6 |
* @copyright 2019-2020 PHPCSUtils Contributors |
| 7 |
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 |
| 8 |
* @link https://github.com/PHPCSStandards/PHPCSUtils |
| 9 |
*/ |
| 10 |
|
| 11 |
namespace PHPCSUtils\Exceptions; |
| 12 |
|
| 13 |
use PHP_CodeSniffer\Exceptions\RuntimeException; |
| 14 |
|
| 15 |
/** |
| 16 |
* Exception thrown when an non-existent token array is requested. |
| 17 |
* |
| 18 |
* @since 1.0.0 |
| 19 |
*/ |
| 20 |
final class InvalidTokenArray extends RuntimeException |
| 21 |
{ |
| 22 |
|
| 23 |
/** |
| 24 |
* Create a new invalid token array exception with a standardized text. |
| 25 |
* |
| 26 |
* @since 1.0.0 |
| 27 |
* |
| 28 |
* @param string $name The name of the token array requested. |
| 29 |
* |
| 30 |
* @return \PHPCSUtils\Exceptions\InvalidTokenArray |
| 31 |
*/ |
| 32 |
public static function create($name) |
| 33 |
{ |
| 34 |
$stack = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
| 35 |
|
| 36 |
return new self( |
| 37 |
\sprintf( |
| 38 |
'Call to undefined method %s::%s()', |
| 39 |
$stack[1]['class'], |
| 40 |
$name |
| 41 |
) |
| 42 |
); |
| 43 |
} |
| 44 |
} |
| 45 |
|