Conditions | 1 |
Paths | 1 |
Total Lines | 17 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | /** |
||
19 | * Execute command |
||
20 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
21 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
22 | * @return void |
||
23 | */ |
||
24 | protected function execute(InputInterface $input, OutputInterface $output) |
||
25 | { |
||
26 | $this->createFileTemplate($input, $output, $this->getApplication()->endpointPath()); |
||
|
|||
27 | } |
||
28 | |||
29 | /** |
||
30 | * File Template |
||
31 | * @param string $namespace |
||
32 | * @param string $name |
||
33 | * @param string $topNSPart |
||
34 | * @return string |
||
35 | */ |
||
63 |
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 sub-classes 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 parent class: