Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
MagicLinkText | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
fromSelSerImpl | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Html2Wt\ConstrainedText; |
5 | |
6 | use Wikimedia\Parsoid\Config\Env; |
7 | use Wikimedia\Parsoid\DOM\Element; |
8 | use Wikimedia\Parsoid\NodeData\DataParsoid; |
9 | |
10 | /** |
11 | * An autolink to an RFC/PMID/ISBN, like `RFC 1234`. |
12 | */ |
13 | class MagicLinkText extends RegExpConstrainedText { |
14 | /** |
15 | * @param string $text |
16 | * @param Element $node |
17 | */ |
18 | public function __construct( string $text, Element $node ) { |
19 | parent::__construct( [ |
20 | 'text' => $text, |
21 | 'node' => $node, |
22 | // there are \b boundaries on either side, and first/last characters |
23 | // are word characters. |
24 | 'badPrefix' => /* RegExp */ '/\w$/uD', |
25 | 'badSuffix' => /* RegExp */ '/^\w/u' |
26 | ] ); |
27 | } |
28 | |
29 | /** |
30 | * @param string $text |
31 | * @param Element $node |
32 | * @param DataParsoid $dataParsoid |
33 | * @param Env $env |
34 | * @param array $opts |
35 | * @return ?MagicLinkText |
36 | */ |
37 | protected static function fromSelSerImpl( |
38 | string $text, Element $node, DataParsoid $dataParsoid, |
39 | Env $env, array $opts ) { |
40 | $stx = $dataParsoid->stx ?? null; |
41 | if ( $stx === 'magiclink' ) { |
42 | return new MagicLinkText( $text, $node ); |
43 | } |
44 | return null; |
45 | } |
46 | } |