3 namespace MediaWiki\Revision
;
11 class ContributionsSegment
{
14 * @var RevisionRecord[]
44 * @param RevisionRecord[] $revisions
45 * @param string[][] $tags Associative array mapping revision IDs to a map of tag names to Message objects
46 * @param string|null $before
47 * @param string|null $after
48 * @param int[] $deltas An associative array mapping a revision Id to the difference in size of this revision
49 * and its parent revision. Values may be null if the size difference is unknown.
50 * @param array $flags Is an associative array, known fields are:
51 * - newest: bool indicating whether this segment is the newest in time
52 * - oldest: bool indicating whether this segment is the oldest in time
54 public function __construct(
62 $this->revisions
= $revisions;
64 $this->before
= $before;
65 $this->after
= $after;
66 $this->deltas
= $deltas;
67 $this->flags
= $flags;
71 * Get tags and associated metadata for a given revision
73 * @param int $revId a revision ID
75 * @return Message[] Associative array mapping tag name to a Message object storing tag display data
77 public function getTagsForRevision( $revId ): array {
78 return $this->tags
[$revId] ??
[];
82 * @return RevisionRecord[]
84 public function getRevisions(): array {
85 return $this->revisions
;
91 public function getBefore(): ?
string {
98 public function getAfter(): ?
string {
103 * Returns the difference in size of the given revision and its parent revision.
104 * Returns null if the size difference is unknown.
105 * @param int $revid Revision id
108 public function getDeltaForRevision( int $revid ): ?
int {
109 return $this->deltas
[$revid] ??
null;
113 * The value of the 'newest' field of the flags passed to the constructor, or false
114 * if that field was not set.
118 public function isNewest(): bool {
119 return $this->flags
['newest'] ??
false;
123 * The value of the 'oldest' field of the flags passed to the constructor, or false
124 * if that field was not set.
128 public function isOldest(): bool {
129 return $this->flags
['oldest'] ??
false;