Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
DataPageResolver | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
resolvePageInDataNamespace | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Chart; |
4 | |
5 | use JsonConfig\JCSingleton; |
6 | use JsonConfig\JCTitle; |
7 | use UnexpectedValueException; |
8 | |
9 | class DataPageResolver { |
10 | /** |
11 | * Look up a page in the Data: namespace. This takes a string like "Foo.tab" and returns a |
12 | * JCTitle object corresponding to Data:Foo.tab; this is a TitleValue subclass which has |
13 | * the attached JsonConfig configuration blob for the underlying data type. |
14 | * |
15 | * All data pages are assumed to live in the NS_DATA namespace, although JsonConfig |
16 | * seems to allow more complex configs that are not fully supported. |
17 | * |
18 | * @param string $pageName Name of a Data page, without the namespace prefix |
19 | * @return ?JCTitle JCTitle object for Data namespace page (or null if invalid) |
20 | * @throws UnexpectedValueException |
21 | */ |
22 | public function resolvePageInDataNamespace( string $pageName ): ?JCTitle { |
23 | // Note: parseTitle cannot return false when given a string |
24 | return JCSingleton::parseTitle( $pageName, NS_DATA ); |
25 | } |
26 | |
27 | } |