Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| EndTagTk | |
0.00% |
0 / 20 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| __clone | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| newFromJsonArray | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\Parsoid\Tokens; |
| 5 | |
| 6 | use Wikimedia\Parsoid\NodeData\DataMw; |
| 7 | use Wikimedia\Parsoid\NodeData\DataParsoid; |
| 8 | |
| 9 | /** |
| 10 | * Represents an HTML end tag token |
| 11 | */ |
| 12 | class EndTagTk extends Token { |
| 13 | /** @var string Name of the end tag */ |
| 14 | private $name; |
| 15 | |
| 16 | /** |
| 17 | * @param string $name |
| 18 | * @param KV[] $attribs |
| 19 | * @param ?DataParsoid $dataParsoid |
| 20 | * @param ?DataMw $dataMw |
| 21 | */ |
| 22 | public function __construct( |
| 23 | string $name, array $attribs = [], |
| 24 | ?DataParsoid $dataParsoid = null, ?DataMw $dataMw = null |
| 25 | ) { |
| 26 | parent::__construct( $dataParsoid, $dataMw ); |
| 27 | $this->name = $name; |
| 28 | $this->attribs = $attribs; |
| 29 | } |
| 30 | |
| 31 | public function __clone() { |
| 32 | parent::__clone(); |
| 33 | // No new non-primitive properties to clone. |
| 34 | } |
| 35 | |
| 36 | public function getName(): string { |
| 37 | return $this->name; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @inheritDoc |
| 42 | */ |
| 43 | public function jsonSerialize(): array { |
| 44 | $ret = [ |
| 45 | 'type' => $this->getType(), |
| 46 | 'name' => $this->name, |
| 47 | 'attribs' => $this->attribs, |
| 48 | 'dataParsoid' => $this->dataParsoid, |
| 49 | ]; |
| 50 | if ( $this->dataMw !== null ) { |
| 51 | $ret['dataMw'] = $this->dataMw; |
| 52 | } |
| 53 | return $ret; |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | public static function newFromJsonArray( array $json ) { |
| 58 | return new self( |
| 59 | $json['name'], |
| 60 | $json['attribs'] ?? [], |
| 61 | $json['dataParsoid'] ?? null, |
| 62 | $json['dataMw'] ?? null |
| 63 | ); |
| 64 | } |
| 65 | } |