Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
35.29% covered (danger)
35.29%
6 / 17
16.67% covered (danger)
16.67%
2 / 12
CRAP
0.00% covered (danger)
0.00%
0 / 1
PPNode_Hash_Text
37.50% covered (danger)
37.50%
6 / 16
16.67% covered (danger)
16.67%
2 / 12
54.26
0.00% covered (danger)
0.00%
0 / 1
 __construct
80.00% covered (warning)
80.00%
4 / 5
0.00% covered (danger)
0.00%
0 / 1
2.03
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNextSibling
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getChildren
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getFirstChild
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getChildrenOfType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getLength
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 item
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getName
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 splitArg
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 splitExt
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 splitHeading
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 * @ingroup Parser
6 */
7
8namespace MediaWiki\Parser;
9
10use InvalidArgumentException;
11use LogicException;
12use Stringable;
13
14/**
15 * @ingroup Parser
16 */
17// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
18class PPNode_Hash_Text implements Stringable, PPNode {
19
20    /** @var string */
21    public $value;
22    /** @var array */
23    private $store;
24    /** @var int */
25    private $index;
26
27    /**
28     * Construct an object using the data from $store[$index]. The rest of the
29     * store array can be accessed via getNextSibling().
30     *
31     * @param array $store
32     * @param int $index
33     */
34    public function __construct( array $store, $index ) {
35        if ( !is_scalar( $store[$index] ) ) {
36            throw new InvalidArgumentException( __CLASS__ . ' given object instead of string' );
37        }
38        $this->value = $store[$index];
39        $this->store = $store;
40        $this->index = $index;
41    }
42
43    public function __toString() {
44        return htmlspecialchars( $this->value, ENT_COMPAT );
45    }
46
47    /** @inheritDoc */
48    public function getNextSibling() {
49        return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
50    }
51
52    /** @inheritDoc */
53    public function getChildren() {
54        return false;
55    }
56
57    /** @inheritDoc */
58    public function getFirstChild() {
59        return false;
60    }
61
62    /** @inheritDoc */
63    public function getChildrenOfType( $name ) {
64        return false;
65    }
66
67    /** @inheritDoc */
68    public function getLength() {
69        return false;
70    }
71
72    /** @inheritDoc */
73    public function item( $i ) {
74        return false;
75    }
76
77    /** @inheritDoc */
78    public function getName() {
79        return '#text';
80    }
81
82    /** @inheritDoc */
83    public function splitArg() {
84        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
85        throw new LogicException( __METHOD__ . ': not supported' );
86    }
87
88    /** @inheritDoc */
89    public function splitExt() {
90        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
91        throw new LogicException( __METHOD__ . ': not supported' );
92    }
93
94    /** @inheritDoc */
95    public function splitHeading() {
96        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
97        throw new LogicException( __METHOD__ . ': not supported' );
98    }
99}
100
101/** @deprecated class alias since 1.43 */
102class_alias( PPNode_Hash_Text::class, 'PPNode_Hash_Text' );