Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 8
LanguageVariantText
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 8
 __construct
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 5
 fromSelSerImpl
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 3
<?php
declare( strict_types = 1 );
namespace Wikimedia\Parsoid\Html2Wt\ConstrainedText;
use Wikimedia\Parsoid\Config\Env;
use Wikimedia\Parsoid\DOM\Element;
use Wikimedia\Parsoid\NodeData\DataParsoid;
use Wikimedia\Parsoid\Utils\DOMUtils;
/**
 * Language Variant markup, like `-{ ... }-`.
 */
class LanguageVariantText extends RegExpConstrainedText {
    /**
     * @param string $text
     * @param Element $node
     */
    public function __construct( string $text, Element $node ) {
        parent::__construct( [
                'text' => $text,
                'node' => $node,
                // at sol vertical bars immediately preceding cause problems in tables
                'badPrefix' => /* RegExp */ '/^\|$/D'
            ]
        );
    }
    /**
     * @param string $text
     * @param Element $node
     * @param DataParsoid $dataParsoid
     * @param Env $env
     * @param array $opts
     * @return ?LanguageVariantText
     */
    protected static function fromSelSerImpl(
        string $text, Element $node, DataParsoid $dataParsoid,
        Env $env, array $opts
    ): ?LanguageVariantText {
        if ( DOMUtils::hasTypeOf( $node, 'mw:LanguageVariant' ) ) {
            return new LanguageVariantText( $text, $node );
        }
        return null;
    }
}