Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| DatabaseHeadingItem | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getHeadingLevel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isPlaceholderHeading | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\DiscussionTools\ThreadItem; |
| 4 | |
| 5 | use MediaWiki\Page\ProperPageIdentity; |
| 6 | use MediaWiki\Revision\RevisionRecord; |
| 7 | |
| 8 | class DatabaseHeadingItem extends DatabaseThreadItem implements HeadingItem { |
| 9 | use HeadingItemTrait; |
| 10 | |
| 11 | private bool $placeholderHeading; |
| 12 | private int $headingLevel; |
| 13 | |
| 14 | // Placeholder headings must have a level higher than real headings (1-6) |
| 15 | private const PLACEHOLDER_HEADING_LEVEL = 99; |
| 16 | |
| 17 | /** |
| 18 | * @param ProperPageIdentity $page |
| 19 | * @param RevisionRecord $rev |
| 20 | * @param string $name |
| 21 | * @param string $id |
| 22 | * @param DatabaseThreadItem|null $parent |
| 23 | * @param bool|string $transcludedFrom |
| 24 | * @param int $level |
| 25 | * @param ?int $headingLevel Heading level (1-6). Use null for a placeholder heading. |
| 26 | */ |
| 27 | public function __construct( |
| 28 | ProperPageIdentity $page, RevisionRecord $rev, |
| 29 | string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level, |
| 30 | ?int $headingLevel |
| 31 | ) { |
| 32 | parent::__construct( $page, $rev, 'heading', $name, $id, $parent, $transcludedFrom, $level ); |
| 33 | $this->placeholderHeading = $headingLevel === null; |
| 34 | $this->headingLevel = $this->placeholderHeading ? static::PLACEHOLDER_HEADING_LEVEL : $headingLevel; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @inheritDoc |
| 39 | */ |
| 40 | public function getHeadingLevel(): int { |
| 41 | return $this->headingLevel; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @inheritDoc |
| 46 | */ |
| 47 | public function isPlaceholderHeading(): bool { |
| 48 | return $this->placeholderHeading; |
| 49 | } |
| 50 | } |