Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TaskSuggesterFactory
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 create
n/a
0 / 0
n/a
0 / 0
0
 createError
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace GrowthExperiments\NewcomerTasks\TaskSuggester;
4
5use GrowthExperiments\NewcomerTasks\ConfigurationLoader\ConfigurationLoader;
6use GrowthExperiments\Util;
7use GrowthExperiments\WikiConfigException;
8use MediaWiki\Status\Status;
9use Psr\Log\LoggerAwareInterface;
10use Psr\Log\LoggerAwareTrait;
11use StatusValue;
12
13abstract class TaskSuggesterFactory implements LoggerAwareInterface {
14
15    use LoggerAwareTrait;
16
17    /**
18     * @param ConfigurationLoader|null $customConfigurationLoader Configuration loader to use instead of the default;
19     * used for querying different topic types (growth vs ores)
20     * @return TaskSuggester
21     */
22    abstract public function create( ?ConfigurationLoader $customConfigurationLoader = null );
23
24    /**
25     * Create a TaskSuggester which just returns a given error.
26     * @param StatusValue $status
27     * @return ErrorForwardingTaskSuggester
28     */
29    protected function createError( StatusValue $status ) {
30        $msg = Status::wrap( $status )->getWikiText( false, false, 'en' );
31        Util::logException( new WikiConfigException( $msg ) );
32        return new ErrorForwardingTaskSuggester( $status );
33    }
34
35}