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 * Content object implementation for representing unknown content.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @since 1.36 (As UnknownContent in 1.34)
21 *
22 * @file
23 * @ingroup Content
24 *
25 * @author Daniel Kinzler
26 */
27
28namespace MediaWiki\Content;
29
30/**
31 * Content object implementation representing unknown content.
32 *
33 * This can be used to handle content for which no ContentHandler exists on the system,
34 * perhaps because the extension that provided it has been removed.
35 *
36 * FallbackContent instances are immutable.
37 *
38 * @ingroup Content
39 */
40class FallbackContent extends AbstractContent {
41
42    /** @var string */
43    private $data;
44
45    /**
46     * @param string $data
47     * @param string $model_id The model ID to handle
48     */
49    public function __construct( $data, $model_id ) {
50        parent::__construct( $model_id );
51
52        $this->data = $data;
53    }
54
55    /**
56     * @return Content $this
57     */
58    public function copy() {
59        // FallbackContent is immutable, so no need to copy.
60        return $this;
61    }
62
63    /**
64     * Returns an empty string.
65     *
66     * @param int $maxlength
67     *
68     * @return string
69     */
70    public function getTextForSummary( $maxlength = 250 ) {
71        return '';
72    }
73
74    /**
75     * Returns the data size in bytes.
76     *
77     * @return int
78     */
79    public function getSize() {
80        return strlen( $this->data );
81    }
82
83    /**
84     * Returns false.
85     *
86     * @param bool|null $hasLinks If it is known whether this content contains links,
87     * provide this information here, to avoid redundant parsing to find out.
88     *
89     * @return bool
90     */
91    public function isCountable( $hasLinks = null ) {
92        return false;
93    }
94
95    /**
96     * @return string data of unknown format and meaning
97     */
98    public function getNativeData() {
99        return $this->getData();
100    }
101
102    /**
103     * @return string data of unknown format and meaning
104     */
105    public function getData() {
106        return $this->data;
107    }
108
109    /**
110     * @param string|null $format
111     *
112     * @return string data of unknown format and meaning
113     */
114    public function serialize( $format = null ) {
115        return $this->getData();
116    }
117
118    /**
119     * Returns an empty string.
120     *
121     * @return string The raw text.
122     */
123    public function getTextForSearchIndex() {
124        return '';
125    }
126
127    /**
128     * @return false
129     */
130    public function getWikitextForTransclusion() {
131        return false;
132    }
133
134    /**
135     * @param string $toModel
136     * @param string $lossy
137     * @return false
138     */
139    public function convert( $toModel, $lossy = '' ) {
140        return false;
141    }
142
143    protected function equalsInternal( Content $that ) {
144        if ( !$that instanceof FallbackContent ) {
145            return false;
146        }
147
148        return $this->getData() == $that->getData();
149    }
150
151}
152/** @deprecated class alias since 1.43 */
153class_alias( FallbackContent::class, 'FallbackContent' );