Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
85.71% covered (warning)
85.71%
6 / 7
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
NullTaskType
85.71% covered (warning)
85.71%
6 / 7
75.00% covered (warning)
75.00%
3 / 4
4.05
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getExtraSearchConditions
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 toJsonArray
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 newFromJsonArray
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace GrowthExperiments\NewcomerTasks\TaskType;
4
5use MediaWiki\Json\JsonUnserializer;
6
7/**
8 * A "fake" task type which only exists to reuse task type related search functionality
9 * when searching for task type candidates which are not task types yet. i18n-related methods
10 * should not be expected to provide anything meaningful.
11 */
12class NullTaskType extends TaskType {
13
14    /** @var string */
15    private $extraSearchConditions;
16
17    /**
18     * @param string $id Task ID.
19     * @param string $extraSearchConditions Extra conditions to append to the search query.
20     */
21    public function __construct( $id, string $extraSearchConditions = '' ) {
22        parent::__construct( $id, TaskType::DIFFICULTY_EASY );
23        $this->extraSearchConditions = $extraSearchConditions;
24    }
25
26    /**
27     * Extra conditions to append to the search query.
28     * @return string
29     */
30    public function getExtraSearchConditions(): string {
31        return $this->extraSearchConditions;
32    }
33
34    /** @inheritDoc */
35    public function toJsonArray(): array {
36        return parent::toJsonArray() + [
37            'extraSearchConditions' => $this->extraSearchConditions,
38        ];
39    }
40
41    /** @inheritDoc */
42    public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) {
43        return new NullTaskType( $json['id'], $json['extraSearchConditions'] );
44    }
45
46}