Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
DatabaseThreadItem
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 11
132
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 getPage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRevision
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 addReply
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
 getType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getParent
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getReplies
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTranscludedFrom
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLevel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
4
5use JsonSerializable;
6use MediaWiki\Page\ProperPageIdentity;
7use MediaWiki\Revision\RevisionRecord;
8
9class DatabaseThreadItem implements JsonSerializable, ThreadItem {
10    use ThreadItemTrait;
11
12    private ProperPageIdentity $page;
13    private RevisionRecord $rev;
14    private string $type;
15    private string $name;
16    private string $id;
17    private ?DatabaseThreadItem $parent;
18    /** @var DatabaseThreadItem[] */
19    private array $replies = [];
20    /** @var string|bool */
21    private $transcludedFrom;
22    private int $level;
23
24    /**
25     * @param ProperPageIdentity $page
26     * @param RevisionRecord $rev
27     * @param string $type
28     * @param string $name
29     * @param string $id
30     * @param DatabaseThreadItem|null $parent
31     * @param bool|string $transcludedFrom
32     * @param int $level
33     */
34    public function __construct(
35        ProperPageIdentity $page, RevisionRecord $rev,
36        string $type, string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level
37    ) {
38        $this->page = $page;
39        $this->rev = $rev;
40        $this->name = $name;
41        $this->id = $id;
42        $this->type = $type;
43        $this->parent = $parent;
44        $this->transcludedFrom = $transcludedFrom;
45        $this->level = $level;
46    }
47
48    /**
49     * @return ProperPageIdentity
50     */
51    public function getPage(): ProperPageIdentity {
52        return $this->page;
53    }
54
55    /**
56     * @return RevisionRecord
57     */
58    public function getRevision(): RevisionRecord {
59        return $this->rev;
60    }
61
62    /**
63     * @inheritDoc
64     */
65    public function getName(): string {
66        return $this->name;
67    }
68
69    /**
70     * @param DatabaseThreadItem $reply Reply comment
71     */
72    public function addReply( DatabaseThreadItem $reply ): void {
73        $this->replies[] = $reply;
74    }
75
76    /**
77     * @inheritDoc
78     */
79    public function getId(): string {
80        return $this->id;
81    }
82
83    /**
84     * @inheritDoc
85     */
86    public function getType(): string {
87        return $this->type;
88    }
89
90    /**
91     * @inheritDoc
92     * @return DatabaseThreadItem|null
93     */
94    public function getParent(): ?ThreadItem {
95        return $this->parent;
96    }
97
98    /**
99     * @inheritDoc
100     * @return DatabaseThreadItem[]
101     */
102    public function getReplies(): array {
103        return $this->replies;
104    }
105
106    /**
107     * @inheritDoc
108     */
109    public function getTranscludedFrom() {
110        return $this->transcludedFrom;
111    }
112
113    /**
114     * @inheritDoc
115     */
116    public function getLevel(): int {
117        return $this->level;
118    }
119}