Debian Codegraph @

includes/parser/PPCustomFrame_Hash.php

raw symbols SCIP
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 /**
25 * Expansion frame with custom arguments
26 * @ingroup Parser
27 */
28 // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
29 class PPCustomFrame_Hash extends PPFrame_Hash {
30
31 /** @var array */
32 public $args;
33
34 /**
35 * @param Preprocessor $preprocessor
36 * @param array $args
37 */
38 public function __construct( $preprocessor, $args ) {
39 parent::__construct( $preprocessor );
40 $this->args = $args;
41 }
42
43 public function __toString() {
44 $s = 'cstmframe{';
45 $first = true;
46 foreach ( $this->args as $name => $value ) {
47 if ( $first ) {
48 $first = false;
49 } else {
50 $s .= ', ';
51 }
52 $s .= "\"$name\":\"" .
53 str_replace( '"', '\\"', $value->__toString() ) . '"';
54 }
55 $s .= '}';
56 return $s;
57 }
58
59 /**
60 * @return bool
61 */
62 public function isEmpty() {
63 return !count( $this->args );
64 }
65
66 /**
67 * @param int|string $index
68 * @return string|false
69 */
70 public function getArgument( $index ) {
71 return $this->args[$index] ?? false;
72 }
73
74 public function getArguments() {
75 return $this->args;
76 }
77 }
78
79 /** @deprecated class alias since 1.43 */
80 class_alias( PPCustomFrame_Hash::class, 'PPCustomFrame_Hash' );