Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
36.84% covered (danger)
36.84%
7 / 19
8.33% covered (danger)
8.33%
1 / 12
CRAP
0.00% covered (danger)
0.00%
0 / 1
PPNode_Hash_Attr
38.89% covered (danger)
38.89%
7 / 18
8.33% covered (danger)
8.33%
1 / 12
51.57
0.00% covered (danger)
0.00%
0 / 1
 __construct
85.71% covered (warning)
85.71%
6 / 7
0.00% covered (danger)
0.00%
0 / 1
2.01
 __toString
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
 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
 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 * 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
22namespace MediaWiki\Parser;
23
24use InvalidArgumentException;
25use LogicException;
26use Stringable;
27
28/**
29 * @ingroup Parser
30 */
31// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
32class PPNode_Hash_Attr implements Stringable, PPNode {
33
34    /** @var string */
35    public $name;
36    /** @var string */
37    public $value;
38    /** @var array */
39    private $store;
40    /** @var int */
41    private $index;
42
43    /**
44     * Construct an object using the data from $store[$index]. The rest of the
45     * store array can be accessed via getNextSibling().
46     *
47     * @param array $store
48     * @param int $index
49     */
50    public function __construct( array $store, $index ) {
51        $descriptor = $store[$index];
52        if ( $descriptor[PPNode_Hash_Tree::NAME][0] !== '@' ) {
53            throw new InvalidArgumentException( __METHOD__ . ': invalid name in attribute descriptor' );
54        }
55        $this->name = substr( $descriptor[PPNode_Hash_Tree::NAME], 1 );
56        $this->value = $descriptor[PPNode_Hash_Tree::CHILDREN][0];
57        $this->store = $store;
58        $this->index = $index;
59    }
60
61    public function __toString() {
62        return "<@{$this->name}>" . htmlspecialchars( $this->value, ENT_COMPAT ) . "</@{$this->name}>";
63    }
64
65    public function getName() {
66        return $this->name;
67    }
68
69    public function getNextSibling() {
70        return PPNode_Hash_Tree::factory( $this->store, $this->index + 1 );
71    }
72
73    public function getChildren() {
74        return false;
75    }
76
77    public function getFirstChild() {
78        return false;
79    }
80
81    public function getChildrenOfType( $name ) {
82        return false;
83    }
84
85    public function getLength() {
86        return false;
87    }
88
89    public function item( $i ) {
90        return false;
91    }
92
93    public function splitArg() {
94        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
95        throw new LogicException( __METHOD__ . ': not supported' );
96    }
97
98    public function splitExt() {
99        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
100        throw new LogicException( __METHOD__ . ': not supported' );
101    }
102
103    public function splitHeading() {
104        // @phan-suppress-previous-line PhanPluginNeverReturnMethod
105        throw new LogicException( __METHOD__ . ': not supported' );
106    }
107}
108
109/** @deprecated class alias since 1.43 */
110class_alias( PPNode_Hash_Attr::class, 'PPNode_Hash_Attr' );