Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
87.50% covered (warning)
87.50%
14 / 16
91.67% covered (success)
91.67%
11 / 12
CRAP
0.00% covered (danger)
0.00%
0 / 1
FallbackContent
93.33% covered (success)
93.33%
14 / 15
91.67% covered (success)
91.67%
11 / 12
13.05
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 copy
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTextForSummary
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isCountable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNativeData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 serialize
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTextForSearchIndex
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getWikitextForTransclusion
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 convert
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 equalsInternal
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
2.15
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 */
6
7namespace MediaWiki\Content;
8
9/**
10 * Content object implementation representing unknown content.
11 *
12 * This can be used to handle content for which no ContentHandler exists on the system,
13 * perhaps because the extension that provided it has been removed.
14 *
15 * FallbackContent instances are immutable.
16 *
17 * @since 1.36 (As UnknownContent in 1.34)
18 * @ingroup Content
19 * @author Daniel Kinzler
20 */
21class FallbackContent extends AbstractContent {
22
23    /** @var string */
24    private $data;
25
26    /**
27     * @param string $data
28     * @param string $model_id The model ID to handle
29     */
30    public function __construct( $data, $model_id ) {
31        parent::__construct( $model_id );
32
33        $this->data = $data;
34    }
35
36    /**
37     * @return Content $this
38     */
39    public function copy() {
40        // FallbackContent is immutable, so no need to copy.
41        return $this;
42    }
43
44    /**
45     * Returns an empty string.
46     *
47     * @param int $maxlength
48     *
49     * @return string
50     */
51    public function getTextForSummary( $maxlength = 250 ) {
52        return '';
53    }
54
55    /**
56     * Returns the data size in bytes.
57     *
58     * @return int
59     */
60    public function getSize() {
61        return strlen( $this->data );
62    }
63
64    /**
65     * Returns false.
66     *
67     * @param bool|null $hasLinks If it is known whether this content contains links,
68     * provide this information here, to avoid redundant parsing to find out.
69     *
70     * @return bool
71     */
72    public function isCountable( $hasLinks = null ) {
73        return false;
74    }
75
76    /**
77     * @return string data of unknown format and meaning
78     */
79    public function getNativeData() {
80        return $this->getData();
81    }
82
83    /**
84     * @return string data of unknown format and meaning
85     */
86    public function getData() {
87        return $this->data;
88    }
89
90    /**
91     * @param string|null $format
92     *
93     * @return string data of unknown format and meaning
94     */
95    public function serialize( $format = null ) {
96        return $this->getData();
97    }
98
99    /**
100     * Returns an empty string.
101     *
102     * @return string The raw text.
103     */
104    public function getTextForSearchIndex() {
105        return '';
106    }
107
108    /**
109     * @return false
110     */
111    public function getWikitextForTransclusion() {
112        return false;
113    }
114
115    /**
116     * @param string $toModel
117     * @param string $lossy
118     * @return false
119     */
120    public function convert( $toModel, $lossy = '' ) {
121        return false;
122    }
123
124    /** @inheritDoc */
125    protected function equalsInternal( Content $that ) {
126        if ( !$that instanceof FallbackContent ) {
127            return false;
128        }
129
130        return $this->getData() == $that->getData();
131    }
132
133}
134/** @deprecated class alias since 1.43 */
135class_alias( FallbackContent::class, 'FallbackContent' );