mediawiki-extensions-Discus.../includes/ThreadItem/DatabaseCommentItem.php
Bartosz Dziewoński 880f9755e0 Separate ContentThreadItem and DatabaseThreadItem etc.
Rename ThreadItem to ContentThreadItem, then create a new ThreadItem
interface containing only the methods that we'll be able to implement
using only the persistently stored data (no parsing), then create a
DatabaseThreadItem. Do the same for CommentItem and HeadingItem.

ThreadItemSet gets a similar treatment, but it's basically only for
Phan's type checking. (This is sad.)

Change-Id: I1633049befe8ec169753b82eb876459af1f63fe8
2022-07-04 23:35:50 +02:00

65 lines
1.5 KiB
PHP

<?php
namespace MediaWiki\Extension\DiscussionTools\ThreadItem;
use DateTimeImmutable;
class DatabaseCommentItem extends DatabaseThreadItem implements CommentItem {
use CommentItemTrait {
getHeading as protected traitGetHeading;
getSubscribableHeading as protected traitGetSubscribableHeading;
}
/** @var string */
private $timestamp;
/** @var string */
private $author;
/**
* @param string $name
* @param string $id
* @param DatabaseThreadItem|null $parent
* @param bool|string $transcludedFrom
* @param int $level
* @param string $timestamp
* @param string $author
*/
public function __construct(
string $name, string $id, ?DatabaseThreadItem $parent, $transcludedFrom, int $level,
string $timestamp, string $author
) {
parent::__construct( 'comment', $name, $id, $parent, $transcludedFrom, $level );
$this->timestamp = $timestamp;
$this->author = $author;
}
/**
* @inheritDoc
*/
public function getAuthor(): string {
return $this->author;
}
/**
* @inheritDoc
*/
public function getTimestamp(): DateTimeImmutable {
return new DateTimeImmutable( $this->timestamp );
}
/**
* @inheritDoc CommentItemTrait::getHeading
* @suppress PhanTypeMismatchReturnSuperType
*/
public function getHeading(): DatabaseHeadingItem {
return $this->traitGetHeading();
}
/**
* @inheritDoc CommentItemTrait::getSubscribableHeading
*/
public function getSubscribableHeading(): ?DatabaseHeadingItem {
return $this->traitGetSubscribableHeading();
}
}