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