Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 15 |
| NonSymbolMatcher | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 15 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| tokenizeDate | |
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 12 |
|||
| <?php | |
| namespace Popy\Calendar\Parser\DateLexer; | |
| use Popy\Calendar\Parser\FormatToken; | |
| use Popy\Calendar\Parser\DateLexerResult; | |
| use Popy\Calendar\Parser\DateLexerInterface; | |
| /** | |
| * Very basic lexer, matching a single token as a litteral one. | |
| */ | |
| class NonSymbolMatcher implements DateLexerInterface | |
| { | |
| /** | |
| * Token. | |
| * | |
| * @var FormatToken | |
| */ | |
| protected $token; | |
| /** | |
| * Class constructor. | |
| * | |
| * @param FormatToken $token | |
| */ | |
| public function __construct(FormatToken $token) | |
| { | |
| $this->token = $token; | |
| } | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function tokenizeDate($string, $offset = 0) | |
| { | |
| if ($this->token->isType(FormatToken::TYPE_EOF)) { | |
| if (strlen($string) <= $offset) { | |
| return new DateLexerResult($offset); | |
| } | |
| return; | |
| } | |
| $len = strlen($this->token->getValue()); | |
| if (substr($string, $offset, $len) === $this->token->getValue()) { | |
| return new DateLexerResult($offset + $len); | |
| } | |
| } | |
| } |