| Conditions | 1 |
| Paths | 1 |
| Total Lines | 14 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 1 |
| Changes | 4 | ||
| Bugs | 0 | Features | 3 |
| 1 | <?php |
||
| 10 | 7 | public function registerCommands(Application $application) |
|
| 11 | { |
||
| 12 | 7 | $config = $application->getKernel() |
|
|
|
|||
| 13 | 7 | ->getContainer() |
|
| 14 | 7 | ->getParameter('mongrate_bundle'); |
|
| 15 | |||
| 16 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\ToggleMigrationCommand($config)); |
|
| 17 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\GenerateMigrationCommand($config)); |
|
| 18 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\UpCommand($config)); |
|
| 19 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\UpAllCommand($config)); |
|
| 20 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\DownCommand($config)); |
|
| 21 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\ListCommand($config)); |
|
| 22 | 7 | $application->add(new \Mongrate\MongrateBundle\Command\TestCommand($config)); |
|
| 23 | 7 | } |
|
| 24 | } |
||
| 25 |
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: