Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
73.33% |
11 / 15 |
|
83.33% |
10 / 12 |
CRAP | |
0.00% |
0 / 1 |
FallbackContent | |
73.33% |
11 / 15 |
|
83.33% |
10 / 12 |
16.20 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
copy | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTextForSummary | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isCountable | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getNativeData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
serialize | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTextForSearchIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getWikitextForTransclusion | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
convert | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
equalsInternal | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
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 | |
28 | /** |
29 | * Content object implementation representing unknown content. |
30 | * |
31 | * This can be used to handle content for which no ContentHandler exists on the system, |
32 | * perhaps because the extension that provided it has been removed. |
33 | * |
34 | * FallbackContent instances are immutable. |
35 | * |
36 | * @ingroup Content |
37 | */ |
38 | class FallbackContent extends AbstractContent { |
39 | |
40 | /** @var string */ |
41 | private $data; |
42 | |
43 | /** |
44 | * @param string $data |
45 | * @param string $model_id The model ID to handle |
46 | */ |
47 | public function __construct( $data, $model_id ) { |
48 | parent::__construct( $model_id ); |
49 | |
50 | $this->data = $data; |
51 | } |
52 | |
53 | /** |
54 | * @return Content $this |
55 | */ |
56 | public function copy() { |
57 | // FallbackContent is immutable, so no need to copy. |
58 | return $this; |
59 | } |
60 | |
61 | /** |
62 | * Returns an empty string. |
63 | * |
64 | * @param int $maxlength |
65 | * |
66 | * @return string |
67 | */ |
68 | public function getTextForSummary( $maxlength = 250 ) { |
69 | return ''; |
70 | } |
71 | |
72 | /** |
73 | * Returns the data size in bytes. |
74 | * |
75 | * @return int |
76 | */ |
77 | public function getSize() { |
78 | return strlen( $this->data ); |
79 | } |
80 | |
81 | /** |
82 | * Returns false. |
83 | * |
84 | * @param bool|null $hasLinks If it is known whether this content contains links, |
85 | * provide this information here, to avoid redundant parsing to find out. |
86 | * |
87 | * @return bool |
88 | */ |
89 | public function isCountable( $hasLinks = null ) { |
90 | return false; |
91 | } |
92 | |
93 | /** |
94 | * @return string data of unknown format and meaning |
95 | */ |
96 | public function getNativeData() { |
97 | return $this->getData(); |
98 | } |
99 | |
100 | /** |
101 | * @return string data of unknown format and meaning |
102 | */ |
103 | public function getData() { |
104 | return $this->data; |
105 | } |
106 | |
107 | /** |
108 | * @param string|null $format |
109 | * |
110 | * @return string data of unknown format and meaning |
111 | */ |
112 | public function serialize( $format = null ) { |
113 | return $this->getData(); |
114 | } |
115 | |
116 | /** |
117 | * Returns an empty string. |
118 | * |
119 | * @return string The raw text. |
120 | */ |
121 | public function getTextForSearchIndex() { |
122 | return ''; |
123 | } |
124 | |
125 | /** |
126 | * @return false |
127 | */ |
128 | public function getWikitextForTransclusion() { |
129 | return false; |
130 | } |
131 | |
132 | /** |
133 | * @param string $toModel |
134 | * @param string $lossy |
135 | * @return false |
136 | */ |
137 | public function convert( $toModel, $lossy = '' ) { |
138 | return false; |
139 | } |
140 | |
141 | protected function equalsInternal( Content $that ) { |
142 | if ( !$that instanceof FallbackContent ) { |
143 | return false; |
144 | } |
145 | |
146 | return $this->getData() == $that->getData(); |
147 | } |
148 | |
149 | } |