Conditions | 9 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 9 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
58 | 8 | public function matches(RequestInterface $request) |
|
59 | { |
||
60 | 8 | if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) { |
|
|
|||
61 | 1 | return false; |
|
62 | } |
||
63 | |||
64 | 7 | if ($this->methods && !in_array($request->getMethod(), $this->methods)) { |
|
65 | 1 | return false; |
|
66 | } |
||
67 | |||
68 | 6 | if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) { |
|
69 | 1 | return false; |
|
70 | } |
||
71 | |||
72 | 5 | if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) { |
|
73 | 1 | return false; |
|
74 | } |
||
75 | |||
76 | 4 | return true; |
|
77 | } |
||
79 |
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.