Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * Service Wirings for WikimediaEvents extension.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 * @since 1.39
23 */
24
25use GeoIp2\Database\Reader;
26use MaxMind\Db\Reader\InvalidDatabaseException;
27use MediaWiki\Logger\LoggerFactory;
28use MediaWiki\MediaWikiServices;
29use WikimediaEvents\WebABTest\WebABTestArticleIdFactory;
30use WikimediaEvents\WikimediaEventsCountryCodeLookup;
31
32return [
33    'WikimediaEvents.WebABTestArticleIdFactory' => static function (): WebABTestArticleIdFactory {
34        return new WebABTestArticleIdFactory();
35    },
36    'WikimediaEventsCountryCodeLookup' => static function (
37        MediaWikiServices $mediaWikiServices
38    ): WikimediaEventsCountryCodeLookup {
39        $reader = null;
40        try {
41            $wmeGeoIp2Path = $mediaWikiServices->getMainConfig()->get( 'WMEGeoIP2Path' );
42            if ( $wmeGeoIp2Path ) {
43                $reader = new Reader( $wmeGeoIp2Path );
44            }
45        } catch ( InvalidDatabaseException | InvalidArgumentException $e ) {
46            LoggerFactory::getInstance( 'WikimediaEvents' )
47                ->error( $e->getMessage() );
48        }
49        return new WikimediaEventsCountryCodeLookup( $reader );
50    },
51];