Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
BaseMaintenanceScript | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
commaList2Array | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\Utilities; |
5 | |
6 | use MediaWiki\Maintenance\Maintenance; |
7 | |
8 | /** |
9 | * Base maintenance script containing constants and methods used in multiple scripts |
10 | * Hopefully the constants can be removed after https://phabricator.wikimedia.org/T271787 is fixed. |
11 | * @author Niklas Laxström |
12 | * @license GPL-2.0-or-later |
13 | */ |
14 | abstract class BaseMaintenanceScript extends Maintenance { |
15 | protected const OPTIONAL = false; |
16 | protected const REQUIRED = true; |
17 | protected const HAS_ARG = true; |
18 | protected const NO_ARG = false; |
19 | |
20 | /** |
21 | * Converts a comma seperated list to an array. Removes empty strings and duplicate values. |
22 | * @return string[] |
23 | */ |
24 | protected static function commaList2Array( string $list ): array { |
25 | return array_unique( |
26 | array_filter( |
27 | array_map( 'trim', explode( ',', $list ) ), |
28 | 'strlen' |
29 | ) |
30 | ); |
31 | } |
32 | } |