Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
RawOresTopic
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 toJsonArray
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 newFromJsonArray
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\NewcomerTasks\Topic;
4
5use MediaWiki\Json\JsonUnserializer;
6
7/**
8 * Represents a single ORES topic (as opposed to OresBasedTopic which is a combination of ORES
9 * topics). This is a special topic type that's not present in the topic list returned by
10 * ConfigurationLoader and as such it cannot be cached or passed to the client side and should
11 * be avoided in user-facing code. i18n-related methods should not be expected to provide anything
12 * meaningful.
13 */
14class RawOresTopic extends OresBasedTopic {
15
16    /**
17     * @param string $id
18     * @param string $oresTopic
19     */
20    public function __construct( string $id, string $oresTopic ) {
21        parent::__construct( $id, null, [ $oresTopic ] );
22    }
23
24    /** @inheritDoc */
25    protected function toJsonArray(): array {
26        return [
27            'id' => $this->getId(),
28            'oresTopic' => $this->getOresTopics()[0],
29        ];
30    }
31
32    /** @inheritDoc */
33    public static function newFromJsonArray( JsonUnserializer $unserializer, array $json ) {
34        return new self( $json['id'], $json['oresTopic'] );
35    }
36
37}