| 1 | <?php |
||
| 14 | final class Token |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Data token type |
||
| 18 | */ |
||
| 19 | const DATA = 'data'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Start of expression token type |
||
| 23 | */ |
||
| 24 | const EXPR_START = 'expr_start'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * End of expression token type |
||
| 28 | */ |
||
| 29 | const EXPR_END = 'expr_end'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Identifier token type |
||
| 33 | */ |
||
| 34 | const IDENTIFIER = 'identifier'; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Whitespace token type |
||
| 38 | */ |
||
| 39 | const WHITESPACE = 'whitespace'; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Number token type |
||
| 43 | */ |
||
| 44 | const NUMBER = 'number'; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * String token type |
||
| 48 | */ |
||
| 49 | const STRING = 'string'; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Operator token type |
||
| 53 | */ |
||
| 54 | const OPERATOR = 'operator'; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Value token type |
||
| 58 | */ |
||
| 59 | const KEYWORD = 'keyword'; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | public $type; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @var mixed |
||
| 68 | */ |
||
| 69 | public $value; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Construct the token with the passed type and value |
||
| 73 | * |
||
| 74 | * @param string $type |
||
| 75 | * @param string $value |
||
| 76 | */ |
||
| 77 | 23 | public function __construct($type, $value = null) |
|
| 82 | |||
| 83 | |||
| 84 | /** |
||
| 85 | * Checks if the token matches the passed type and/or value |
||
| 86 | * |
||
| 87 | * @param mixed $type |
||
| 88 | * @param mixed $value |
||
| 89 | * @return bool |
||
| 90 | */ |
||
| 91 | 20 | public function match($type, $value = null) |
|
| 100 | } |