Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
4 / 4
CRAP
100.00% covered (success)
100.00%
1 / 1
OresBasedTopic
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
4 / 4
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getOresTopics
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toJsonArray
100.00% covered (success)
100.00%
5 / 5
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\Topic;
4
5use MediaWiki\Json\JsonUnserializer;
6
7class OresBasedTopic extends Topic {
8
9    /** @var string[] */
10    private $oresTopics;
11
12    /**
13     * @param string $id Topic ID, a string consisting of lowercase alphanumeric characters
14     *   and dashes. E.g. 'biology'.
15     * @param string|null $groupId Topic group, for visual grouping. E.g. 'science'.
16     * @param string[] $oresTopics ORES topic IDs which define this topic.
17     */
18    public function __construct( string $id, ?string $groupId, array $oresTopics ) {
19        parent::__construct( $id, $groupId );
20        $this->oresTopics = $oresTopics;
21    }
22
23    /**
24     * ORES topic IDs which define this topic.
25     * @return string[]
26     */
27    public function getOresTopics(): array {
28        return $this->oresTopics;
29    }
30
31    /** @inheritDoc */
32    protected function toJsonArray(): array {
33        return [
34            'id' => $this->getId(),
35            'groupId' => $this->getGroupId(),
36            'oresTopics' => $this->getOresTopics(),
37        ];
38    }
39
40    /** @inheritDoc */
41    public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) {
42        return new OresBasedTopic( $json['id'], $json['groupId'], $json['oresTopics'] );
43    }
44
45}