Conditions | 2 |
Paths | 2 |
Total Lines | 9 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
37 | public function setScore($score) |
||
38 | { |
||
39 | if (!$this instanceof ScoreAwareInterface) |
||
40 | { |
||
41 | throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, ScoreAwareInterface::class)); // @codeCoverageIgnore |
||
42 | } |
||
43 | $this->score = $score; |
||
44 | return $this; |
||
45 | } |
||
46 | |||
48 |
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: