Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
63.64% |
7 / 11 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
SelserContext | |
63.64% |
7 / 11 |
|
75.00% |
3 / 4 |
7.73 | |
0.00% |
0 / 1 |
__construct | |
50.00% |
4 / 8 |
|
0.00% |
0 / 1 |
4.12 | |||
getPageBundle | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRevisionID | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getContent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Edit; |
4 | |
5 | use MediaWiki\Content\Content; |
6 | use UnexpectedValueException; |
7 | use Wikimedia\Parsoid\Core\PageBundle; |
8 | use Wikimedia\Parsoid\Core\SelserData; |
9 | |
10 | /** |
11 | * Value object representing contextual information needed by Parsoid for selective serialization ("selser") of |
12 | * modified HTML. |
13 | * |
14 | * @see SelserData |
15 | * |
16 | * @since 1.40 |
17 | */ |
18 | class SelserContext { |
19 | private PageBundle $pageBundle; |
20 | |
21 | private int $revId; |
22 | |
23 | private ?Content $content; |
24 | |
25 | /** |
26 | * @param PageBundle $pageBundle |
27 | * @param int $revId |
28 | * @param Content|null $content |
29 | */ |
30 | public function __construct( PageBundle $pageBundle, int $revId, ?Content $content = null ) { |
31 | if ( !$revId && !$content ) { |
32 | throw new UnexpectedValueException( |
33 | 'If $revId is 0, $content must be given. ' . |
34 | 'If we can\'t load the content from a revision, we have to stash it.' |
35 | ); |
36 | } |
37 | |
38 | $this->pageBundle = $pageBundle; |
39 | $this->revId = $revId; |
40 | $this->content = $content; |
41 | } |
42 | |
43 | public function getPageBundle(): PageBundle { |
44 | return $this->pageBundle; |
45 | } |
46 | |
47 | public function getRevisionID(): int { |
48 | return $this->revId; |
49 | } |
50 | |
51 | public function getContent(): ?Content { |
52 | return $this->content; |
53 | } |
54 | |
55 | } |