| Conditions | 3 |
| Paths | 4 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.2098 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 33 | 5 | private function getModifiedSince(Request $request):\DateTime |
|
| 34 | { |
||
| 35 | 5 | if ($request->headers->has(self::HTTP_HEADER_NAME)) { |
|
| 36 | try { |
||
| 37 | 1 | $string = $request->headers->get(self::HTTP_HEADER_NAME); |
|
| 38 | 1 | return new \DateTime($string); |
|
| 39 | } catch (\TypeError|\Exception $e) { |
||
| 40 | $this->logger->notice(sprintf('If-Modified-Since Header has a unexpected value, exception was %s', $e->getMessage())); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | 5 | return new \DateTime('@1'); |
|
| 45 | } |
||
| 46 | |||
| 48 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: