use Maslosoft\Manganel\Interfaces\MaxScoreAwareInterface;
16
use UnexpectedValueException;
17
18
/**
19
* MaxScoreAwareTrait
20
*
21
* @see MaxScoreAwareInterface
22
* @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
*/
24
trait MaxScoreAwareTrait
25
{
26
27
private $maxScore = 0.0;
28
29
1
public function getMaxScore()
30
{
31
1
if (!$this instanceof MaxScoreAwareInterface)
32
{
33
throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, MaxScoreAwareInterface::class)); // @codeCoverageIgnore
Accessing maxScore on the interface Maslosoft\Manganel\Inter...\MaxScoreAwareInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a
concrete implementation of the interface.
throw new UnexpectedValueException(sprintf('Class `%s` using `%s` must implement `%s`', get_class($this), __CLASS__, MaxScoreAwareInterface::class)); // @codeCoverageIgnore
Accessing maxScore on the interface Maslosoft\Manganel\Inter...\MaxScoreAwareInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a
concrete implementation of the interface.
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: