Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
14 | 7 | public function parse($value, Presentation $presentation) |
|
15 | { |
||
16 | 7 | if (is_int($value)) { |
|
17 | // We don't use format 'U' as the TZ would be UTC |
||
18 | 1 | $date = \DateTime::createFromFormat('Y-m-d', date('Y-m-d', $value)); |
|
19 | 6 | } elseif (preg_match('#\d{4}-\d{1,2}-\d{1,2}#', $value)) { |
|
20 | 1 | $date = \DateTime::createFromFormat('Y-m-d', $value); |
|
21 | } else { |
||
22 | 5 | throw new ConfigException('Dates must be a string in the format YYYY-MM-DD.'); |
|
23 | } |
||
24 | |||
25 | 2 | $date->setTime(0, 0, 0); |
|
26 | |||
27 | 2 | $presentation->date = new Date($date); |
|
|
|||
28 | 2 | } |
|
29 | } |
||
30 |