Conditions | 1 |
Paths | 1 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
44 | public function runImport( \Iterator $entityPageIterator ) { |
||
45 | $pagesImporter = $this->factory->newPagesImporter( |
||
46 | $this->newReporter(), |
||
47 | new ConsoleStatsReporter( $this->output ), |
||
48 | $this->onAborted |
||
49 | ); |
||
50 | |||
51 | pcntl_signal( SIGINT, [ $pagesImporter, 'stop' ] ); |
||
52 | pcntl_signal( SIGTERM, [ $pagesImporter, 'stop' ] ); |
||
53 | |||
54 | $pagesImporter->importPages( $entityPageIterator ); |
||
55 | } |
||
56 | |||
65 |
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: