| Conditions | 5 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public function resolveInterface(string $class): string |
||
| 30 | { |
||
| 31 | if (interface_exists($class)) { |
||
| 32 | return $class; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (class_exists($class)) { |
||
| 36 | /** @phpstan-var class-string[]|false $interfaces */ |
||
| 37 | $interfaces = class_implements($class); |
||
| 38 | |||
| 39 | if ($interfaces) { |
||
|
1 ignored issue
–
show
|
|||
| 40 | if (count($interfaces) > 1) { |
||
| 41 | $interfaces = implode(', ', $interfaces); |
||
| 42 | throw new LogicException("Don't know which interface to choose from for $class: $interfaces."); |
||
| 43 | } |
||
| 44 | |||
| 45 | return reset($interfaces); |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | throw new LogicException("Unable to determine the interface to implement for $class."); |
||
| 50 | } |
||
| 52 |
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.