| Conditions | 5 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 5.9256 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | 1 | protected function doClean(LoggerInterface $logger = null) |
|
| 26 | { |
||
| 27 | // BASE must be child of HEAD. |
||
| 28 | 1 | if ($this->getParent() !== null && $this->getParent()->getName() !== 'head') { |
|
|
|
|||
| 29 | return false; |
||
| 30 | } |
||
| 31 | |||
| 32 | // Must have either "href" or "target" attribute or both. |
||
| 33 | 1 | if (!$this->hasAttribute('href') && !$this->hasAttribute('target')) { |
|
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | 1 | return true; |
|
| 38 | } |
||
| 39 | } |
||
| 40 |
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: