Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
CaptionHandler
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 4
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 before
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
 after
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Html2Wt\DOMHandlers;
5
6use Wikimedia\Parsoid\DOM\Element;
7use Wikimedia\Parsoid\DOM\Node;
8use Wikimedia\Parsoid\Html2Wt\SerializerState;
9use Wikimedia\Parsoid\Utils\DOMCompat;
10use Wikimedia\Parsoid\Utils\DOMDataUtils;
11
12class CaptionHandler extends DOMHandler {
13
14    public function __construct() {
15        parent::__construct( false );
16    }
17
18    /** @inheritDoc */
19    public function handle(
20        Element $node, SerializerState $state, bool $wrapperUnmodified = false
21    ): ?Node {
22        $dp = DOMDataUtils::getDataParsoid( $node );
23        // Serialize the tag itself
24        $tableTag = $this->serializeTableTag(
25            $dp->startTagSrc ?? '|+', null, $state, $node,
26            $wrapperUnmodified
27        );
28        $state->emitChunk( $tableTag, $node );
29        $state->serializeChildren( $node );
30        return $node->nextSibling;
31    }
32
33    /** @inheritDoc */
34    public function before( Element $node, Node $otherNode, SerializerState $state ): array {
35        return ( DOMCompat::nodeName( $otherNode ) !== 'table' )
36            ? [ 'min' => 1, 'max' => $this->maxNLsInTable( $node, $otherNode ) ]
37            : [ 'min' => 0, 'max' => $this->maxNLsInTable( $node, $otherNode ) ];
38    }
39
40    /** @inheritDoc */
41    public function after( Element $node, Node $otherNode, SerializerState $state ): array {
42        return [ 'min' => 1, 'max' => $this->maxNLsInTable( $node, $otherNode ) ];
43    }
44
45}