Implement lexer class for tokenization and replace all line endings by PHP_EOL
This commit is contained in:
@ -4,5 +4,13 @@ namespace App\Service\SnipContent;
|
||||
|
||||
class Lexer
|
||||
{
|
||||
public static function tokenize(string $text): array {
|
||||
$text = str_replace("\r", '', $text);
|
||||
return explode(PHP_EOL, $text);
|
||||
}
|
||||
|
||||
public static function reconstruct(array $tokens): string
|
||||
{
|
||||
return implode(PHP_EOL, $tokens);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user