Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
3 / 3 |
SplitConflictUtils | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
3 / 3 |
splitText | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
mergeTextLines | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
|||
addTargetBlankToLinks | |
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
<?php | |
namespace TwoColConflict; | |
/** | |
* @license GPL-2.0-or-later | |
* @author Christoph Jauera <christoph.jauera@wikimedia.de> | |
*/ | |
class SplitConflictUtils { | |
/** | |
* @param string $text | |
* | |
* @return string[] | |
*/ | |
public static function splitText( string $text ): array { | |
return explode( "\n", str_replace( [ "\r\n", "\r" ], "\n", $text ) ); | |
} | |
/** | |
* @param string[] $textLines | |
* | |
* @return string | |
*/ | |
public static function mergeTextLines( array $textLines ): string { | |
return str_replace( [ "\r\n", "\r" ], "\n", implode( "\r\n", $textLines ) ); | |
} | |
/** | |
* @param string $html | |
* | |
* @return string | |
*/ | |
public static function addTargetBlankToLinks( string $html ): string { | |
return preg_replace( '/<a\b(?![^<>]*\starget=)/', '<a target="_blank"', $html ); | |
} | |
} |