Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| PPCustomFrame_Hash | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| __toString | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 | |||
| isEmpty | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getArgument | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getArguments | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | * @ingroup Parser |
| 6 | */ |
| 7 | |
| 8 | namespace MediaWiki\Parser; |
| 9 | |
| 10 | /** |
| 11 | * Expansion frame with custom arguments |
| 12 | * @ingroup Parser |
| 13 | */ |
| 14 | // phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps |
| 15 | class PPCustomFrame_Hash extends PPFrame_Hash { |
| 16 | |
| 17 | /** @var array */ |
| 18 | public $args; |
| 19 | |
| 20 | /** |
| 21 | * @param Preprocessor $preprocessor |
| 22 | * @param array $args |
| 23 | */ |
| 24 | public function __construct( $preprocessor, $args ) { |
| 25 | parent::__construct( $preprocessor ); |
| 26 | $this->args = $args; |
| 27 | } |
| 28 | |
| 29 | public function __toString() { |
| 30 | $s = 'cstmframe{'; |
| 31 | $first = true; |
| 32 | foreach ( $this->args as $name => $value ) { |
| 33 | if ( $first ) { |
| 34 | $first = false; |
| 35 | } else { |
| 36 | $s .= ', '; |
| 37 | } |
| 38 | $s .= "\"$name\":\"" . |
| 39 | str_replace( '"', '\\"', $value->__toString() ) . '"'; |
| 40 | } |
| 41 | $s .= '}'; |
| 42 | return $s; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @return bool |
| 47 | */ |
| 48 | public function isEmpty() { |
| 49 | return !count( $this->args ); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @param int|string $index |
| 54 | * @return string|false |
| 55 | */ |
| 56 | public function getArgument( $index ) { |
| 57 | return $this->args[$index] ?? false; |
| 58 | } |
| 59 | |
| 60 | /** @inheritDoc */ |
| 61 | public function getArguments() { |
| 62 | return $this->args; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** @deprecated class alias since 1.43 */ |
| 67 | class_alias( PPCustomFrame_Hash::class, 'PPCustomFrame_Hash' ); |