| Conditions | 4 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | public function process(HTTPRequest $request, callable $delegate) |
||
| 49 | { |
||
| 50 | $allowedHosts = $this->getAllowedHosts(); |
||
| 51 | |||
| 52 | // check allowed hosts |
||
| 53 | if ($allowedHosts |
||
|
|
|||
| 54 | && !Director::is_cli() |
||
| 55 | && !in_array($request->getHeader('Host'), $allowedHosts) |
||
| 56 | ) { |
||
| 57 | return new HTTPResponse('Invalid Host', 400); |
||
| 58 | } |
||
| 59 | |||
| 60 | return $delegate($request); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
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.