Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
PPCustomFrame_Hash
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 __toString
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
12
 isEmpty
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getArgument
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getArguments
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 * Expansion frame with custom arguments
24 * @ingroup Parser
25 */
26// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
27class PPCustomFrame_Hash extends PPFrame_Hash {
28
29    /** @var array */
30    public $args;
31
32    /**
33     * @param Preprocessor $preprocessor
34     * @param array $args
35     */
36    public function __construct( $preprocessor, $args ) {
37        parent::__construct( $preprocessor );
38        $this->args = $args;
39    }
40
41    public function __toString() {
42        $s = 'cstmframe{';
43        $first = true;
44        foreach ( $this->args as $name => $value ) {
45            if ( $first ) {
46                $first = false;
47            } else {
48                $s .= ', ';
49            }
50            $s .= "\"$name\":\"" .
51                str_replace( '"', '\\"', $value->__toString() ) . '"';
52        }
53        $s .= '}';
54        return $s;
55    }
56
57    /**
58     * @return bool
59     */
60    public function isEmpty() {
61        return !count( $this->args );
62    }
63
64    /**
65     * @param int|string $index
66     * @return string|false
67     */
68    public function getArgument( $index ) {
69        return $this->args[$index] ?? false;
70    }
71
72    public function getArguments() {
73        return $this->args;
74    }
75}