| Conditions | 7 |
| Paths | 7 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function render(ElementInterface $element, $ignoreViewPartial = false) |
||
| 24 | { |
||
| 25 | $renderer = $this->getView(); |
||
| 26 | if (!method_exists($renderer, 'plugin')) { |
||
| 27 | // Bail early if renderer is not pluggable |
||
| 28 | return ''; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($element instanceof ViewPartialProviderInterface && !$ignoreViewPartial) { |
||
| 32 | $partial = $element->getViewPartial(); |
||
| 33 | return $renderer->partial($partial, ['element' => $element]); |
||
| 34 | } |
||
| 35 | |||
| 36 | if ($element instanceof CoreElementInterface) { |
||
| 37 | $helper = $element->getViewHelper(); |
||
| 38 | if (is_string($helper)) { |
||
| 39 | $helper = $renderer->plugin($helper); |
||
| 40 | } |
||
| 41 | if ($helper instanceof HelperInterface) { |
||
| 42 | $helper->setView($renderer); |
||
|
|
|||
| 43 | } |
||
| 44 | return $helper($element); |
||
| 45 | } |
||
| 46 | |||
| 47 | return parent::render($element); |
||
| 48 | } |
||
| 49 | } |
||
| 50 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: