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