Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | use MediaWiki\Config\ServiceOptions; |
4 | use MediaWiki\IPInfo\InfoManager; |
5 | use MediaWiki\IPInfo\InfoRetriever\BlockInfoRetriever; |
6 | use MediaWiki\IPInfo\InfoRetriever\ContributionInfoRetriever; |
7 | use MediaWiki\IPInfo\InfoRetriever\GeoIp2EnterpriseInfoRetriever; |
8 | use MediaWiki\IPInfo\InfoRetriever\GeoLite2InfoRetriever; |
9 | use MediaWiki\IPInfo\InfoRetriever\InfoRetriever; |
10 | use MediaWiki\IPInfo\InfoRetriever\IPoidInfoRetriever; |
11 | use MediaWiki\IPInfo\InfoRetriever\ReaderFactory; |
12 | use MediaWiki\IPInfo\Logging\LoggerFactory as IPInfoLoggerFactory; |
13 | use MediaWiki\Logger\LoggerFactory; |
14 | use MediaWiki\MediaWikiServices; |
15 | |
16 | // PHPUnit doesn't understand code coverage for code outside of classes/functions, |
17 | // like service wiring files. see T310509 |
18 | // @codeCoverageIgnoreStart |
19 | return [ |
20 | 'IPInfoGeoLite2InfoRetriever' => static function ( MediaWikiServices $services ): InfoRetriever { |
21 | $config = $services->getMainConfig(); |
22 | if ( $config->get( 'IPInfoGeoIP2EnterprisePath' ) ) { |
23 | return new GeoIp2EnterpriseInfoRetriever( |
24 | new ServiceOptions( |
25 | GeoIp2EnterpriseInfoRetriever::CONSTRUCTOR_OPTIONS, $config |
26 | ), |
27 | $services->get( 'ReaderFactory' ) |
28 | ); |
29 | } |
30 | return new GeoLite2InfoRetriever( |
31 | new ServiceOptions( |
32 | GeoLite2InfoRetriever::CONSTRUCTOR_OPTIONS, $config |
33 | ), |
34 | $services->get( 'ReaderFactory' ) |
35 | ); |
36 | }, |
37 | 'IPInfoIPoidInfoRetriever' => static function ( MediaWikiServices $services ): IPoidInfoRetriever { |
38 | $config = $services->getMainConfig(); |
39 | return new IPoidInfoRetriever( |
40 | new ServiceOptions( |
41 | IPoidInfoRetriever::CONSTRUCTOR_OPTIONS, $config |
42 | ), |
43 | $services->get( 'HttpRequestFactory' ), |
44 | LoggerFactory::getInstance( 'IPInfo' ) |
45 | ); |
46 | }, |
47 | 'IPInfoBlockInfoRetriever' => static function ( MediaWikiServices $services ): BlockInfoRetriever { |
48 | return new BlockInfoRetriever( $services->getBlockManager() ); |
49 | }, |
50 | 'IPInfoContributionInfoRetriever' => static function ( MediaWikiServices $services ): ContributionInfoRetriever { |
51 | return new ContributionInfoRetriever( $services->getDBLoadBalancerFactory() ); |
52 | }, |
53 | 'IPInfoInfoManager' => static function ( MediaWikiServices $services ): InfoManager { |
54 | return new InfoManager( [ |
55 | $services->get( 'IPInfoGeoLite2InfoRetriever' ), |
56 | $services->get( 'IPInfoIPoidInfoRetriever' ), |
57 | $services->get( 'IPInfoBlockInfoRetriever' ), |
58 | $services->get( 'IPInfoContributionInfoRetriever' ), |
59 | ] ); |
60 | }, |
61 | 'IPInfoLoggerFactory' => static function ( MediaWikiServices $services ): IPInfoLoggerFactory { |
62 | return new IPInfoLoggerFactory( |
63 | $services->getActorStore(), |
64 | $services->getDBLoadBalancerFactory() |
65 | ); |
66 | }, |
67 | 'ReaderFactory' => static function (): ReaderFactory { |
68 | return new ReaderFactory(); |
69 | } |
70 | ]; |
71 | |
72 | // @codeCoverageIgnoreEnd |