Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 9
CRAP
0.00% covered (danger)
0.00%
0 / 1
NullTaskTypeHandler
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 9
110
0.00% covered (danger)
0.00%
0 / 1
 getNullTaskType
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 validateTaskTypeConfiguration
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 validateTaskTypeObject
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSearchTerm
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 getChangeTags
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 createTaskType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getSubmissionHandler
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\NewcomerTasks\TaskType;
4
5use GrowthExperiments\NewcomerTasks\SubmissionHandler;
6use InvalidArgumentException;
7use LogicException;
8use StatusValue;
9
10/**
11 * A "fake" task type handler for searching for task type candidates. Since it will return an
12 * empty search term, the TaskSuggester will return a set of "tasks" which meet all the
13 * non-tasktype-specific requirements and can be used for generating new tasks (for task types
14 * where that kind of thing makes sense).
15 */
16class NullTaskTypeHandler extends TaskTypeHandler {
17
18    /**
19     * Get a null task type. This task type should only be used for searching,
20     * with the $useCache flag off.
21     * @param string $id Task ID.
22     * @param string $extraSearchConditions Extra conditions to append to the search query.
23     * @return TaskType
24     */
25    public static function getNullTaskType(
26        string $id,
27        string $extraSearchConditions = ''
28    ): TaskType {
29        $taskType = new NullTaskType( $id, $extraSearchConditions );
30        $taskType->setHandlerId( 'null' );
31        return $taskType;
32    }
33
34    public function __construct() {
35        // parent() call omitted intentionally.
36    }
37
38    /** @inheritDoc */
39    public function getId(): string {
40        return 'null';
41    }
42
43    /** @inheritDoc */
44    public function validateTaskTypeConfiguration( string $taskTypeId, array $config ): StatusValue {
45        return StatusValue::newFatal( 'growthexperiments-homepage-suggestededits-config-nulltasktype' );
46    }
47
48    /** @inheritDoc */
49    public function validateTaskTypeObject( TaskType $taskType ): StatusValue {
50        return StatusValue::newFatal( 'growthexperiments-homepage-suggestededits-config-nulltasktype' );
51    }
52
53    /** @inheritDoc */
54    public function getSearchTerm( TaskType $taskType ): string {
55        if ( !$taskType instanceof NullTaskType ) {
56            throw new InvalidArgumentException( 'Invalid task type' );
57        }
58        return $taskType->getExtraSearchConditions();
59    }
60
61    /** @inheritDoc */
62    public function getChangeTags( ?string $taskType = null ): array {
63        return [];
64    }
65
66    /**
67     * @inheritDoc
68     * @suppress PhanPluginNeverReturnMethod LSP/ISP violation
69     */
70    public function createTaskType( string $taskTypeId, array $config ): TaskType {
71        throw new LogicException( 'This should never be called' );
72    }
73
74    /** @inheritDoc */
75    public function getSubmissionHandler(): SubmissionHandler {
76        return new NullSubmissionHandler();
77    }
78}