Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
35.29% |
6 / 17 |
|
16.67% |
2 / 12 |
CRAP | |
0.00% |
0 / 1 |
PPNode_Hash_Text | |
37.50% |
6 / 16 |
|
16.67% |
2 / 12 |
54.26 | |
0.00% |
0 / 1 |
__construct | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
2.03 | |||
__toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getNextSibling | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getChildren | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getFirstChild | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getChildrenOfType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLength | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
item | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
splitArg | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
splitExt | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
splitHeading | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | * @ingroup Parser |
20 | */ |
21 | |
22 | namespace MediaWiki\Parser; |
23 | |
24 | use InvalidArgumentException; |
25 | use LogicException; |
26 | use Stringable; |
27 | |
28 | /** |
29 | * @ingroup Parser |
30 | */ |
31 | // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps |
32 | class PPNode_Hash_Text implements Stringable, PPNode { |
33 | |
34 | /** @var string */ |
35 | public $value; |
36 | /** @var array */ |
37 | private $store; |
38 | /** @var int */ |
39 | private $index; |
40 | |
41 | /** |
42 | * Construct an object using the data from $store[$index]. The rest of the |
43 | * store array can be accessed via getNextSibling(). |
44 | * |
45 | * @param array $store |
46 | * @param int $index |
47 | */ |
48 | public function __construct( array $store, $index ) { |
49 | if ( !is_scalar( $store[$index] ) ) { |
50 | throw new InvalidArgumentException( __CLASS__ . ' given object instead of string' ); |
51 | } |
52 | $this->value = $store[$index]; |
53 | $this->store = $store; |
54 | $this->index = $index; |
55 | } |
56 | |
57 | public function __toString() { |
58 | return htmlspecialchars( $this->value, ENT_COMPAT ); |
59 | } |
60 | |
61 | public function getNextSibling() { |
62 | return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 ); |
63 | } |
64 | |
65 | public function getChildren() { |
66 | return false; |
67 | } |
68 | |
69 | public function getFirstChild() { |
70 | return false; |
71 | } |
72 | |
73 | public function getChildrenOfType( $name ) { |
74 | return false; |
75 | } |
76 | |
77 | public function getLength() { |
78 | return false; |
79 | } |
80 | |
81 | public function item( $i ) { |
82 | return false; |
83 | } |
84 | |
85 | public function getName() { |
86 | return '#text'; |
87 | } |
88 | |
89 | public function splitArg() { |
90 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
91 | throw new LogicException( __METHOD__ . ': not supported' ); |
92 | } |
93 | |
94 | public function splitExt() { |
95 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
96 | throw new LogicException( __METHOD__ . ': not supported' ); |
97 | } |
98 | |
99 | public function splitHeading() { |
100 | // @phan-suppress-previous-line PhanPluginNeverReturnMethod |
101 | throw new LogicException( __METHOD__ . ': not supported' ); |
102 | } |
103 | } |
104 | |
105 | /** @deprecated class alias since 1.43 */ |
106 | class_alias( PPNode_Hash_Text::class, 'PPNode_Hash_Text' ); |