Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
TaskSuggesterFactory | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
create | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
createError | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\NewcomerTasks\TaskSuggester; |
4 | |
5 | use GrowthExperiments\NewcomerTasks\ConfigurationLoader\ConfigurationLoader; |
6 | use GrowthExperiments\Util; |
7 | use GrowthExperiments\WikiConfigException; |
8 | use MediaWiki\Status\Status; |
9 | use Psr\Log\LoggerAwareInterface; |
10 | use Psr\Log\LoggerAwareTrait; |
11 | use StatusValue; |
12 | |
13 | abstract 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 | } |