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