Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ApiFeatureUsageQueryEngineElasticaConnection
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 3
42
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
20
 getServerList
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getMaxConnectionAttempts
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\ApiFeatureUsage;
4
5use InvalidArgumentException;
6use MediaWiki\Extension\Elastica\ElasticaConnection;
7
8/**
9 * Class to create the connection
10 */
11class ApiFeatureUsageQueryEngineElasticaConnection extends ElasticaConnection {
12    /** @var array */
13    private $options = [];
14
15    /**
16     * @param array|null $options
17     */
18    public function __construct( $options = null ) {
19        if ( !is_array( $options ) ) {
20            $options = [];
21        }
22
23        if ( empty( $options['serverList'] ) || !is_array( $options['serverList'] ) ) {
24            throw new InvalidArgumentException( __METHOD__ . ': serverList is not set or is not valid.' );
25        }
26
27        $this->options = $options + [
28            'maxConnectionAttempts' => 1,
29        ];
30    }
31
32    /** @inheritDoc */
33    public function getServerList() {
34        return $this->options['serverList'];
35    }
36
37    /** @inheritDoc */
38    public function getMaxConnectionAttempts() {
39        return $this->options['maxConnectionAttempts'];
40    }
41}