Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
BaseMaintenanceScript
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 commaList2Array
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\Utilities;
5
6use 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 */
14abstract 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}