Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
19 / 19 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| ZQuote | |
100.00% |
19 / 19 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDefinition | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |||
| isValid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getSerialized | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| getZValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * WikiLambda ZQuote |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
| 8 | * @license MIT |
| 9 | */ |
| 10 | |
| 11 | namespace MediaWiki\Extension\WikiLambda\ZObjects; |
| 12 | |
| 13 | use MediaWiki\Extension\WikiLambda\Registry\ZTypeRegistry; |
| 14 | |
| 15 | class ZQuote extends ZObject { |
| 16 | |
| 17 | /** |
| 18 | * Construct a ZQuote instance that can contain any value |
| 19 | * |
| 20 | * @param mixed $value |
| 21 | */ |
| 22 | public function __construct( $value = '' ) { |
| 23 | $this->data[ ZTypeRegistry::Z_QUOTE_VALUE ] = $value; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @inheritDoc |
| 28 | */ |
| 29 | public static function getDefinition(): array { |
| 30 | return [ |
| 31 | 'type' => [ |
| 32 | 'type' => ZTypeRegistry::Z_REFERENCE, |
| 33 | 'value' => ZTypeRegistry::Z_QUOTE, |
| 34 | ], |
| 35 | 'keys' => [ |
| 36 | ZTypeRegistry::Z_QUOTE_VALUE => [ |
| 37 | 'type' => ZTypeRegistry::BUILTIN_ANY, |
| 38 | 'default' => '' |
| 39 | ], |
| 40 | ], |
| 41 | ]; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @inheritDoc |
| 46 | */ |
| 47 | public function isValid(): bool { |
| 48 | // For ZQuote, any value is valid by definition. |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @inheritDoc |
| 54 | */ |
| 55 | public function getSerialized( $form = self::FORM_CANONICAL ) { |
| 56 | return (object)[ |
| 57 | ZTypeRegistry::Z_OBJECT_TYPE => ZTypeRegistry::Z_QUOTE, |
| 58 | ZTypeRegistry::Z_QUOTE_VALUE => $this->getZValue() |
| 59 | ]; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get the raw content of the value quoted by this ZQuote instance |
| 64 | * |
| 65 | * @return mixed |
| 66 | */ |
| 67 | public function getZValue() { |
| 68 | return $this->data[ ZTypeRegistry::Z_QUOTE_VALUE ]; |
| 69 | } |
| 70 | } |