Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
91.67% |
11 / 12 |
AbstractPreg | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2.00 | |
91.67% |
11 / 12 |
tokenizeDate | |
0.00% |
0 / 1 |
2.00 | |
91.67% |
11 / 12 |
<?php | |
namespace Popy\Calendar\Parser\DateLexer; | |
use Popy\Calendar\Parser\DateLexerResult; | |
use Popy\Calendar\Parser\PregDateLexerInterface; | |
/** | |
* Abstract implementation of Preg based lexers. | |
*/ | |
abstract class AbstractPreg implements PregDateLexerInterface | |
{ | |
/** | |
* @inheritDoc | |
*/ | |
public function tokenizeDate($string, $offset = 0) | |
{ | |
$match = []; | |
if (!preg_match( | |
'/\G'.$this->getExpression().'/', | |
$string, | |
$match, | |
PREG_OFFSET_CAPTURE, | |
$offset | |
)) { | |
return null; | |
} | |
$this->hydrateResult( | |
$res = new DateLexerResult($offset + strlen($match[0][0])), | |
$match | |
); | |
return $res; | |
} | |
} |