| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public static function injectAtEnd(string $text, string $html) : string |
||
| 33 | { |
||
| 34 | preg_match_all('%<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>%si', $html, $result, PREG_PATTERN_ORDER); |
||
| 35 | |||
| 36 | if(empty($result[1])) { |
||
| 37 | return '<p>'.$text.'</p>'; |
||
| 38 | } |
||
| 39 | |||
| 40 | $tagName = array_pop($result[1]); |
||
| 41 | $pos = strrpos($html, '</'.$tagName.'>'); |
||
| 42 | |||
| 43 | if(in_array(strtolower($tagName), self::$newParaTags)) { |
||
| 44 | $replace = '</'.$tagName.'><p>'.$text.'</p>'; |
||
| 45 | } else { |
||
| 46 | $replace = $text.'</'.$tagName.'>'; |
||
| 47 | } |
||
| 48 | |||
| 49 | return substr_replace($html, $replace, $pos, strlen($html)); |
||
|
|
|||
| 50 | } |
||
| 52 |