| Conditions | 6 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6 |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 13 | 45 | public function getTokenAt($code, $cursor) |
|
| 14 | { |
||
| 15 | 45 | $regExp = '/(?<y>\d{4})-(?<m>\d{2})-(?<d>\d{2})T(?<h>\d{2}):(?<i>\d{2}):(?<s>\d{2})Z/A'; |
|
| 16 | 45 | if (!preg_match($regExp, $code, $matches, null, $cursor)) { |
|
| 17 | 37 | return null; |
|
| 18 | } |
||
| 19 | |||
| 20 | 15 | if (!checkdate($matches['m'], $matches['d'], $matches['y']) || |
|
| 21 | 15 | !($matches['h'] < 24 && $matches['i'] < 60 && $matches['s'] < 60)) { |
|
| 22 | 2 | throw new SyntaxErrorException(sprintf('Invalid datetime value "%s"', $matches[0])); |
|
| 23 | } |
||
| 24 | |||
| 25 | 15 | return new Token( |
|
| 26 | 15 | Token::T_DATE, |
|
| 27 | 15 | $matches[0], |
|
| 28 | 15 | $cursor, |
|
| 29 | 15 | $cursor + strlen($matches[0]) |
|
| 30 | 15 | ); |
|
| 31 | } |
||
| 32 | } |
||
| 33 |