Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 10 |
MagicLinkText | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 10 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
fromSelSerImpl | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 4 |
<?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; | |
/** | |
* An autolink to an RFC/PMID/ISBN, like `RFC 1234`. | |
*/ | |
class MagicLinkText extends RegExpConstrainedText { | |
/** | |
* @param string $text | |
* @param Element $node | |
*/ | |
public function __construct( string $text, Element $node ) { | |
parent::__construct( [ | |
'text' => $text, | |
'node' => $node, | |
// there are \b boundaries on either side, and first/last characters | |
// are word characters. | |
'badPrefix' => /* RegExp */ '/\w$/uD', | |
'badSuffix' => /* RegExp */ '/^\w/u' | |
] ); | |
} | |
/** | |
* @param string $text | |
* @param Element $node | |
* @param DataParsoid $dataParsoid | |
* @param Env $env | |
* @param array $opts | |
* @return ?MagicLinkText | |
*/ | |
protected static function fromSelSerImpl( | |
string $text, Element $node, DataParsoid $dataParsoid, | |
Env $env, array $opts ) { | |
$stx = $dataParsoid->stx ?? null; | |
if ( $stx === 'magiclink' ) { | |
return new MagicLinkText( $text, $node ); | |
} | |
return null; | |
} | |
} |