| Conditions | 6 |
| Paths | 4 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 27 | public function generateMention(Mention $mention): ?AbstractInline |
|
| 34 | { |
||
| 35 | 27 | $result = \call_user_func_array($this->callback, [$mention]); |
|
| 36 | 27 | if ($result === null) { |
|
| 37 | 3 | return null; |
|
| 38 | } |
||
| 39 | |||
| 40 | 24 | if ($result instanceof AbstractInline && ! ($result instanceof Mention)) { |
|
| 41 | 6 | return $result; |
|
| 42 | } |
||
| 43 | |||
| 44 | 18 | if ($result instanceof Mention && $result->hasUrl()) { |
|
| 45 | 9 | return $mention; |
|
| 46 | } |
||
| 47 | |||
| 48 | 9 | throw new \RuntimeException('CallbackGenerator callable must set the URL on the passed mention and return the mention, return a new AbstractInline based object or null if the mention is not a match'); |
|
| 49 | } |
||
| 50 | } |
||
| 51 |