Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
SearchableNamespaceListBuilder | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
getCuratedNamespaces | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace AdvancedSearch; |
4 | |
5 | /** |
6 | * @license GPL-2.0-or-later |
7 | */ |
8 | class SearchableNamespaceListBuilder { |
9 | |
10 | /** |
11 | * Get a curated list of namespaces. Adds Main namespace and removes unnamed namespaces |
12 | * @param array<int,string> $configNamespaces Mapping namespace ids to localized names |
13 | * @return array<int,string> |
14 | */ |
15 | public static function getCuratedNamespaces( array $configNamespaces ): array { |
16 | // Make sure the main namespace is listed with a non-empty name |
17 | if ( isset( $configNamespaces[NS_MAIN] ) && !$configNamespaces[NS_MAIN] ) { |
18 | $configNamespaces[NS_MAIN] = wfMessage( 'blanknamespace' )->text(); |
19 | } |
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 | } |