Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.64% covered (warning)
63.64%
7 / 11
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SelserContext
63.64% covered (warning)
63.64%
7 / 11
75.00% covered (warning)
75.00%
3 / 4
7.73
0.00% covered (danger)
0.00%
0 / 1
 __construct
50.00% covered (danger)
50.00%
4 / 8
0.00% covered (danger)
0.00%
0 / 1
4.12
 getPageBundle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRevisionID
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getContent
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Edit;
4
5use Content;
6use UnexpectedValueException;
7use Wikimedia\Parsoid\Core\PageBundle;
8use 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 */
18class 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    /**
44     * @return PageBundle
45     */
46    public function getPageBundle(): PageBundle {
47        return $this->pageBundle;
48    }
49
50    /**
51     * @return int
52     */
53    public function getRevisionID(): int {
54        return $this->revId;
55    }
56
57    /**
58     * @return Content|null
59     */
60    public function getContent(): ?Content {
61        return $this->content;
62    }
63
64}