| Conditions | 3 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | public function __invoke(ElementInterface $element = null, $labelContent = null, $position = null) |
||
| 20 | { |
||
| 21 | // Set $required to a default of true | existing elements required-value |
||
| 22 | $required = ($element->hasAttribute('required') ? true : false); |
||
|
|
|||
| 23 | |||
| 24 | if (true === $required) { |
||
| 25 | $labelContent = sprintf( |
||
| 26 | '%s<span class="required-mark">*</span>', |
||
| 27 | $labelContent |
||
| 28 | ); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $this->openTag() . $labelContent . $this->closeTag(); |
||
| 32 | } |
||
| 33 | } |
If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe: