| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types = 1); |
||
| 38 | public function parse(string $input): \DateInterval |
||
| 39 | { |
||
| 40 | $input = trim($this->normalizer->normalize($input)); |
||
| 41 | |||
| 42 | $definition = Pattern::DEFINE . Pattern::INTEGER . Pattern::TIME_PART . ')'; |
||
| 43 | $expression = $definition . Pattern::INTERVAL_ONLY; |
||
| 44 | |||
| 45 | if (preg_match($expression, $input, $matches)) { |
||
| 46 | return \DateInterval::createFromDateString($input); |
||
| 47 | } |
||
| 48 | |||
| 49 | throw new FormatException("Given string is not a valid time interval."); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.