Conditions | 6 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 6.0493 |
Changes | 0 |
1 | <?php |
||
42 | 157 | protected function relationQuery($keys, $constraints): ReadCommandInterface |
|
43 | { |
||
44 | // Constraints can be on relation attributes : builder must be used |
||
45 | // @todo Handle "bulk select" |
||
46 | 157 | if (count($keys) !== 1 || $constraints || $this->constraints) { |
|
|
|||
47 | 27 | return $this->query($keys, $constraints)->by($this->distantKey); |
|
48 | } |
||
49 | |||
50 | 136 | if ($this->relationQuery) { |
|
51 | 60 | return $this->relationQuery->where($this->distantKey, $keys[0]); |
|
52 | } |
||
53 | |||
54 | 89 | $query = $this->distant->queries()->keyValue($this->distantKey, $keys[0]); |
|
55 | |||
56 | 89 | if (!$query) { |
|
57 | return $this->query($keys, $constraints)->by($this->distantKey); |
||
58 | } |
||
59 | |||
60 | 89 | return $this->relationQuery = $query->by($this->distantKey); |
|
61 | } |
||
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.