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