| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer): HtmlElement |
||
| 15 | { |
||
| 16 | if (! $inline instanceof Link) { |
||
| 17 | throw new InvalidArgumentException('Inline must be instance of ' . Link::class); |
||
| 18 | } |
||
| 19 | |||
| 20 | $attributes = []; |
||
| 21 | |||
| 22 | $url = $inline->getUrl(); |
||
| 23 | |||
| 24 | if (strpos($url, '*') === 0) { |
||
| 25 | $url = substr($url, 1); |
||
| 26 | |||
| 27 | $attributes['target'] = '_blank'; |
||
| 28 | } |
||
| 29 | |||
| 30 | $attributes['href'] = $url; |
||
| 31 | |||
| 32 | return new HtmlElement( |
||
| 33 | 'a', |
||
| 34 | $attributes, |
||
| 35 | $htmlRenderer->renderInlines($inline->children()) |
||
|
|
|||
| 36 | ); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: