Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
WikibaseServices | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
getService | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getEntityLookup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPropertyDataTypeLookup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getEntityLookupWithoutCache | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace WikibaseQuality\ConstraintReport; |
4 | |
5 | use MediaWiki\MediaWikiServices; |
6 | use Wikibase\DataModel\Services\Lookup\EntityLookup; |
7 | use Wikibase\DataModel\Services\Lookup\PropertyDataTypeLookup; |
8 | |
9 | /** |
10 | * These services should really be registered by Wikibase, |
11 | * but Wikibase doesn’t register them yet |
12 | * and we need them to be registered as services for some tests, |
13 | * so for now we register them on Wikibase’ behalf. |
14 | * |
15 | * @license GPL-2.0-or-later |
16 | */ |
17 | class WikibaseServices { |
18 | |
19 | public const ENTITY_LOOKUP = 'WBQC_EntityLookup'; |
20 | public const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21 | public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
22 | |
23 | private static function getService( ?MediaWikiServices $services, $name ) { |
24 | if ( $services === null ) { |
25 | $services = MediaWikiServices::getInstance(); |
26 | } |
27 | return $services->getService( $name ); |
28 | } |
29 | |
30 | /** |
31 | * @param MediaWikiServices|null $services |
32 | * @return EntityLookup |
33 | */ |
34 | public static function getEntityLookup( MediaWikiServices $services = null ) { |
35 | return self::getService( $services, self::ENTITY_LOOKUP ); |
36 | } |
37 | |
38 | /** |
39 | * @param MediaWikiServices|null $services |
40 | * @return PropertyDataTypeLookup |
41 | */ |
42 | public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) { |
43 | return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP ); |
44 | } |
45 | |
46 | /** |
47 | * @param MediaWikiServices|null $services |
48 | * @return EntityLookup |
49 | */ |
50 | public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) { |
51 | return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE ); |
52 | } |
53 | |
54 | } |