Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
SearchableNamespaceListBuilder | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
getCuratedNamespaces | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace AdvancedSearch; |
4 | |
5 | /** |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | class SearchableNamespaceListBuilder { |
9 | |
10 | private const MAIN_NAMESPACE = 'blanknamespace'; |
11 | |
12 | /** |
13 | * Get a curated list of namespaces. Adds Main namespace and removes unnamed namespaces |
14 | * @param string[] $configNamespaces Key is namespace ID and value namespace string |
15 | * @return string[] |
16 | */ |
17 | public static function getCuratedNamespaces( array $configNamespaces ): array { |
18 | // Make sure the main namespace is listed with a non-empty name |
19 | $configNamespaces[ NS_MAIN ] = wfMessage( self::MAIN_NAMESPACE )->text(); |
20 | |
21 | // Remove entries that still have an empty name |
22 | $configNamespaces = array_filter( $configNamespaces ); |
23 | |
24 | ksort( $configNamespaces ); |
25 | return $configNamespaces; |
26 | } |
27 | |
28 | } |