| Conditions | 7 |
| Paths | 6 |
| Total Lines | 30 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 56 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 22 | public function validate(Configuration $configuration) |
||
| 23 | { |
||
| 24 | parent::validate($configuration); |
||
| 25 | |||
| 26 | // If not valid, then we are done. |
||
| 27 | if (!$this->isValid) { |
||
|
|
|||
| 28 | return; |
||
| 29 | } |
||
| 30 | |||
| 31 | // If no cleaning, then we are done. |
||
| 32 | if ($configuration->get('clean-strategy') == 'none') { |
||
| 33 | return; |
||
| 34 | } |
||
| 35 | |||
| 36 | // "base" must be child of "head". |
||
| 37 | if ($this->getParent() === null || $this->getParent()->getName() !== 'head') { |
||
| 38 | $this->handleValidationError( |
||
| 39 | $configuration, |
||
| 40 | 'Base element must be a child of a "head" element.' |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | // Must have either "href" or "target" attribute or both. |
||
| 45 | if (!$this->hasAttribute('href') && !$this->hasAttribute('target')) { |
||
| 46 | $this->handleValidationError( |
||
| 47 | $configuration, |
||
| 48 | 'Base element must have either "href" or "target" attribute or both.' |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 53 |
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.