Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
SplitConflictUtils | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
splitText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
mergeTextLines | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addTargetBlankToLinks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace TwoColConflict; |
4 | |
5 | /** |
6 | * @license GPL-2.0-or-later |
7 | * @author Christoph Jauera <christoph.jauera@wikimedia.de> |
8 | */ |
9 | class SplitConflictUtils { |
10 | |
11 | /** |
12 | * @param string $text |
13 | * |
14 | * @return string[] |
15 | */ |
16 | public static function splitText( string $text ): array { |
17 | return explode( "\n", str_replace( [ "\r\n", "\r" ], "\n", $text ) ); |
18 | } |
19 | |
20 | /** |
21 | * @param string[] $textLines |
22 | * |
23 | * @return string |
24 | */ |
25 | public static function mergeTextLines( array $textLines ): string { |
26 | return str_replace( [ "\r\n", "\r" ], "\n", implode( "\r\n", $textLines ) ); |
27 | } |
28 | |
29 | /** |
30 | * @param string $html |
31 | * |
32 | * @return string |
33 | */ |
34 | public static function addTargetBlankToLinks( string $html ): string { |
35 | return preg_replace( '/<a\b(?![^<>]*\starget=)/', '<a target="_blank"', $html ); |
36 | } |
37 | |
38 | } |