| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function handle(Request $request, Closure $next) |
||
| 13 | { |
||
| 14 | $response = $next($request); |
||
| 15 | |||
| 16 | if ($request->isMethod('get')) { |
||
| 17 | $etag = md5($response->getContent()); |
||
| 18 | $requestEtag = str_replace('"', '', $request->getETags()); |
||
| 19 | |||
| 20 | if ($requestEtag && $requestEtag[0] == $etag) { |
||
|
|
|||
| 21 | $response->setNotModified(); |
||
| 22 | } |
||
| 23 | |||
| 24 | $response->setEtag($etag); |
||
| 25 | } |
||
| 26 | |||
| 27 | return $response; |
||
| 28 | } |
||
| 29 | } |
||
| 30 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.