| Total Complexity | 5 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | final class Tokenizer |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The singleton instance. |
||
| 13 | * |
||
| 14 | * @var static |
||
| 15 | */ |
||
| 16 | private static self $instance; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The map of token instances by type. |
||
| 20 | * |
||
| 21 | * @var array<int, Token> |
||
| 22 | */ |
||
| 23 | private array $tokensMap; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Retrieve the singleton instance |
||
| 27 | * |
||
| 28 | * @return static |
||
| 29 | */ |
||
| 30 | 126 | public static function instance(): static |
|
| 31 | { |
||
| 32 | 126 | return static::$instance ??= new static(); |
|
|
|
|||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Instantiate the class. |
||
| 37 | * |
||
| 38 | */ |
||
| 39 | 1 | private function __construct() |
|
| 40 | { |
||
| 41 | 1 | $this->setTokensMap(); |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Set the tokens map |
||
| 46 | * |
||
| 47 | * @return void |
||
| 48 | */ |
||
| 49 | 1 | private function setTokensMap(): void |
|
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Turn the given value into a token |
||
| 60 | * |
||
| 61 | * @param string $value |
||
| 62 | * @return Token |
||
| 63 | */ |
||
| 64 | 126 | public function toToken(string $value): Token |
|
| 69 | } |
||
| 70 | } |
||
| 71 |