Conditions | 3 |
Paths | 4 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
33 | 10 | private function getModifiedSince(Request $request):\DateTime |
|
34 | { |
||
35 | 10 | if ($request->headers->has(self::HTTP_HEADER_NAME)) { |
|
36 | try { |
||
37 | 5 | $string = $request->headers->get(self::HTTP_HEADER_NAME); |
|
38 | 5 | return new \DateTime($string); |
|
39 | 2 | } catch (\TypeError|\Exception $e) { |
|
40 | 2 | $this->logger->notice(sprintf('If-Modified-Since Header has a unexpected value, exception was %s', $e->getMessage())); |
|
41 | } |
||
42 | } |
||
43 | |||
44 | 8 | 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: