| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 35 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 36 | { |
||
| 37 | $this->ensureExtensionLoaded('apc'); |
||
| 38 | |||
| 39 | $key = $input->getArgument('key'); |
||
| 40 | $success = $this->getCacheTool()->apc_delete($key); |
||
| 41 | |||
| 42 | if ($output->isVerbose()) { |
||
|
|
|||
| 43 | if ($success) { |
||
| 44 | $output->writeln("<comment>APC key <info>{$key}</info> was deleted</comment>"); |
||
| 45 | } else { |
||
| 46 | $output->writeln("<comment>APC key <info>{$key}</info> could not be deleted.</comment>"); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | return $success ? 0 : 1; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
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: