Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
ApiFeatureUsageQueryEngine
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 getEngine
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0
 suggestDateRange
n/a
0 / 0
n/a
0 / 0
0
1<?php
2
3namespace MediaWiki\Extension\ApiFeatureUsage;
4
5use MediaWiki\Config\Config;
6use MediaWiki\Config\ConfigException;
7use MediaWiki\Status\Status;
8use MediaWiki\Utils\MWTimestamp;
9
10abstract class ApiFeatureUsageQueryEngine {
11    /** @var array */
12    public $options;
13
14    /**
15     * @param Config $config
16     * @return ApiFeatureUsageQueryEngine
17     */
18    public static function getEngine( Config $config ) {
19        $conf = $config->get( 'ApiFeatureUsageQueryEngineConf' );
20        if ( isset( $conf['factory'] ) ) {
21            return $conf['factory']( $conf );
22        }
23
24        if ( isset( $conf['class'] ) ) {
25            return new $conf['class']( $conf );
26        }
27
28        throw new ConfigException( '$wgApiFeatureUsageQueryEngineConf does not define an engine' );
29    }
30
31    /**
32     * @param array $options
33     */
34    public function __construct( array $options ) {
35        $this->options = $options;
36    }
37
38    /**
39     * Execute the query
40     *
41     * Status object's value is an array of arrays, with the subarrays each
42     * having keys 'feature', 'date', and 'count'.
43     *
44     * @param string $agent
45     * @param MWTimestamp $start
46     * @param MWTimestamp $end
47     * @param string[]|null $features
48     * @return Status
49     */
50    abstract public function execute(
51        $agent, MWTimestamp $start, MWTimestamp $end, array $features = null
52    );
53
54    /**
55     * Get a suggested date range
56     * @return MWTimestamp[]
57     */
58    abstract public function suggestDateRange();
59}