| Conditions | 2 |
| Paths | 2 |
| Total Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 46 | public function setIndex($index) |
||
| 47 | { |
||
| 48 | if (!$this instanceof IndexAwareInterface) |
||
| 49 | { |
||
| 50 | throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, IndexAwareInterface::class)); // @codeCoverageIgnore |
||
| 51 | } |
||
| 52 | $this->index = $index; |
||
| 53 | return $this; |
||
| 54 | } |
||
| 55 | |||
| 57 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: