Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
85.71% covered (warning)
85.71%
12 / 14
90.91% covered (success)
90.91%
10 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
FallbackContent
92.31% covered (success)
92.31%
12 / 13
90.91% covered (success)
90.91%
10 / 11
12.07
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
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
 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    /**
24     * @param string $data
25     * @param string $model_id The model ID to handle
26     */
27    public function __construct(
28        private readonly string $data,
29        string $model_id,
30    ) {
31        parent::__construct( $model_id );
32    }
33
34    /** @inheritDoc */
35    public function copy() {
36        // FallbackContent is immutable, so no need to copy.
37        return $this;
38    }
39
40    /**
41     * Returns an empty string.
42     *
43     * @param int $maxlength
44     *
45     * @return string
46     */
47    public function getTextForSummary( $maxlength = 250 ) {
48        return '';
49    }
50
51    /**
52     * Returns the data size in bytes.
53     *
54     * @return int
55     */
56    public function getSize() {
57        return strlen( $this->data );
58    }
59
60    /**
61     * Returns false.
62     *
63     * @param bool|null $hasLinks If it is known whether this content contains links,
64     * provide this information here, to avoid redundant parsing to find out.
65     *
66     * @return bool
67     */
68    public function isCountable( $hasLinks = null ) {
69        return false;
70    }
71
72    /**
73     * @return string data of unknown format and meaning
74     */
75    public function getData() {
76        return $this->data;
77    }
78
79    /**
80     * @param string|null $format
81     *
82     * @return string data of unknown format and meaning
83     */
84    public function serialize( $format = null ) {
85        return $this->getData();
86    }
87
88    /**
89     * Returns an empty string.
90     *
91     * @return string The raw text.
92     */
93    public function getTextForSearchIndex() {
94        return '';
95    }
96
97    /**
98     * @return false
99     */
100    public function getWikitextForTransclusion() {
101        return false;
102    }
103
104    /**
105     * @param string $toModel
106     * @param string $lossy
107     * @return false
108     */
109    public function convert( $toModel, $lossy = '' ) {
110        return false;
111    }
112
113    /** @inheritDoc */
114    protected function equalsInternal( Content $that ) {
115        if ( !$that instanceof FallbackContent ) {
116            return false;
117        }
118
119        return $this->getData() == $that->getData();
120    }
121
122}
123/** @deprecated class alias since 1.43 */
124class_alias( FallbackContent::class, 'FallbackContent' );