Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
FigureHandler | |
0.00% |
0 / 11 |
|
0.00% |
0 / 4 |
72 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
handle | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
before | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
after | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Html2Wt\DOMHandlers; |
5 | |
6 | use Wikimedia\Parsoid\Core\MediaStructure; |
7 | use Wikimedia\Parsoid\DOM\Element; |
8 | use Wikimedia\Parsoid\DOM\Node; |
9 | use Wikimedia\Parsoid\Html2Wt\LinkHandlerUtils; |
10 | use Wikimedia\Parsoid\Html2Wt\SerializerState; |
11 | use Wikimedia\Parsoid\Utils\DOMUtils; |
12 | use Wikimedia\Parsoid\Utils\WTUtils; |
13 | |
14 | class FigureHandler extends DOMHandler { |
15 | |
16 | public function __construct() { |
17 | parent::__construct( false ); |
18 | } |
19 | |
20 | /** @inheritDoc */ |
21 | public function handle( |
22 | Element $node, SerializerState $state, bool $wrapperUnmodified = false |
23 | ): ?Node { |
24 | LinkHandlerUtils::figureHandler( |
25 | $state, $node, MediaStructure::parse( $node ) |
26 | ); |
27 | return $node->nextSibling; |
28 | } |
29 | |
30 | /** @inheritDoc */ |
31 | public function before( Element $node, Node $otherNode, SerializerState $state ): array { |
32 | if ( WTUtils::isNewElt( $node ) && DOMUtils::atTheTop( $node->parentNode ) ) { |
33 | return [ 'min' => 1 ]; |
34 | } |
35 | return []; |
36 | } |
37 | |
38 | /** @inheritDoc */ |
39 | public function after( Element $node, Node $otherNode, SerializerState $state ): array { |
40 | if ( WTUtils::isNewElt( $node ) && DOMUtils::atTheTop( $node->parentNode ) ) { |
41 | return [ 'min' => 1 ]; |
42 | } |
43 | return []; |
44 | } |
45 | |
46 | } |