Conditions | 2 |
Paths | 2 |
Total Lines | 9 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
42 | 1 | public function setIndex($index) |
|
43 | { |
||
44 | 1 | if (!$this instanceof IndexAwareInterface) |
|
45 | { |
||
46 | throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, IndexAwareInterface::class)); // @codeCoverageIgnore |
||
47 | } |
||
48 | 1 | $this->index = $index; |
|
49 | 1 | return $this; |
|
50 | } |
||
51 | |||
53 |
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: