Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ConfigWrapper | |
100.00% |
6 / 6 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| has | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace MediaWiki\Babel\Config; |
| 6 | |
| 7 | use MediaWiki\Config\Config; |
| 8 | use MediaWiki\Extension\CommunityConfiguration\Access\MediaWikiConfigRouter; |
| 9 | |
| 10 | class ConfigWrapper implements Config { |
| 11 | |
| 12 | public function __construct( |
| 13 | private readonly MediaWikiConfigRouter $configRouter, |
| 14 | ) { |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @inheritDoc |
| 19 | */ |
| 20 | public function get( $name ) { |
| 21 | $value = $this->configRouter->get( $name ); |
| 22 | if ( is_object( $value ) ) { |
| 23 | // CommunityConfiguration passes objects instead of associative arrays (which Babel |
| 24 | // expects). This affects eg. BabelCategoryNames. See T369608. |
| 25 | $value = wfObjectToArray( $value ); |
| 26 | } |
| 27 | return $value; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @inheritDoc |
| 32 | */ |
| 33 | public function has( $name ): bool { |
| 34 | return $this->configRouter->has( $name ); |
| 35 | } |
| 36 | } |