Conditions | 4 |
Paths | 5 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4.5923 |
Changes | 0 |
1 | <?php |
||
35 | 24 | public static function parseDate($dateValue) |
|
36 | { |
||
37 | 24 | foreach (self::$dateFormats as $dateFormat) { |
|
38 | 24 | if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { |
|
39 | 24 | return $date; |
|
40 | } |
||
41 | } |
||
42 | |||
43 | // attempt a fallback for unusual formatting |
||
44 | 11 | if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { |
|
45 | 11 | return $date; |
|
46 | } |
||
47 | |||
48 | throw new UnexpectedValueException(sprintf( |
||
49 | 'Unparseable cookie date string "%s"', |
||
50 | $dateValue |
||
51 | )); |
||
52 | } |
||
53 | } |
||
54 |