ParsoidParser: Record ParserOptions watcher on ParserOutput object
[mediawiki.git] / includes / Revision / ContributionsSegment.php
blobf9d9cfdaa3468c2dd33419d8392137d4ad88a5f4
1 <?php
3 namespace MediaWiki\Revision;
5 use Message;
7 /**
8 * @newable
9 * @since 1.35
11 class ContributionsSegment {
13 /**
14 * @var RevisionRecord[]
16 private $revisions;
18 /**
19 * @var string[][]
21 private $tags;
23 /**
24 * @var string|null
26 private $before;
28 /**
29 * @var string|null
31 private $after;
33 /**
34 * @var array
36 private $deltas;
38 /**
39 * @var array
41 private $flags;
43 /**
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(
55 array $revisions,
56 array $tags,
57 ?string $before,
58 ?string $after,
59 array $deltas = [],
60 array $flags = []
61 ) {
62 $this->revisions = $revisions;
63 $this->tags = $tags;
64 $this->before = $before;
65 $this->after = $after;
66 $this->deltas = $deltas;
67 $this->flags = $flags;
70 /**
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] ?? [];
81 /**
82 * @return RevisionRecord[]
84 public function getRevisions(): array {
85 return $this->revisions;
88 /**
89 * @return string|null
91 public function getBefore(): ?string {
92 return $this->before;
95 /**
96 * @return string|null
98 public function getAfter(): ?string {
99 return $this->after;
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
106 * @return int|null
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.
116 * @return bool
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.
126 * @return bool
128 public function isOldest(): bool {
129 return $this->flags['oldest'] ?? false;