| Conditions | 5 | 
| Paths | 3 | 
| Total Lines | 18 | 
| Code Lines | 8 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 3 | 
| CRAP Score | 14.6179 | 
| Changes | 3 | ||
| Bugs | 0 | Features | 2 | 
| 1 | <?php  | 
            ||
| 28 | 1 | protected function doClean(LoggerInterface $logger)  | 
            |
| 29 |     { | 
            ||
| 30 | // "base" element must be child of "head" element.  | 
            ||
| 31 | 1 |         if ($this->getParent() !== null && $this->getParent()->getName() !== 'head') { | 
            |
| 
                                                                                                    
                        
                         | 
                |||
| 32 |             $logger->debug('Element "base" must be a "head" element child.'); | 
            ||
| 33 | |||
| 34 | return false;  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | // Must have either "href" or "target" attribute or both.  | 
            ||
| 38 |         if (!$this->hasAttribute('href') && !$this->hasAttribute('target')) { | 
            ||
| 39 |             $logger->debug('Element "base" must have either the "href" or "target" attribute or both.'); | 
            ||
| 40 | 1 | ||
| 41 | return false;  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 | return true;  | 
            ||
| 45 | }  | 
            ||
| 46 | }  | 
            ||
| 47 | 
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: