| Conditions | 1 |
| Paths | 1 |
| Total Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 1 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 7 | protected function configure() |
|
| 22 | { |
||
| 23 | $this |
||
| 24 | 7 | ->setName('REPORT') |
|
| 25 | 7 | ->setDescription('Get a report from the robot') |
|
| 26 | 7 | ->setHelp(<<<EOT |
|
| 27 | 7 | The <info>REPORT</info> instruction will get a report from the robot; |
|
| 28 | |||
| 29 | <info>./toyrobot</info> <comment>REPORT</comment> |
||
| 30 | |||
| 31 | EOT |
||
| 32 | ); |
||
| 33 | 7 | } |
|
| 34 | |||
| 50 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: