Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ImgHandler
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 2
12
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 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Html2Wt\DOMHandlers;
5
6use Wikimedia\Parsoid\Core\MediaStructure;
7use Wikimedia\Parsoid\DOM\Element;
8use Wikimedia\Parsoid\DOM\Node;
9use Wikimedia\Parsoid\Html2Wt\LinkHandlerUtils;
10use Wikimedia\Parsoid\Html2Wt\SerializerState;
11use Wikimedia\Parsoid\Utils\DOMCompat;
12use Wikimedia\Parsoid\Utils\DOMUtils;
13
14class ImgHandler 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        if ( DOMUtils::hasRel( $node, 'mw:externalImage' ) ) {
25            $state->serializer->emitWikitext( DOMCompat::getAttribute( $node, 'src' ) ?? '', $node );
26        } else {
27            LinkHandlerUtils::figureHandler( $state, $node, new MediaStructure( $node ) );
28        }
29        return $node->nextSibling;
30    }
31
32}