Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ExtLinkText | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| fromSelSerImpl | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| 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\Config\SiteConfig; |
| 8 | use Wikimedia\Parsoid\DOM\Element; |
| 9 | use Wikimedia\Parsoid\NodeData\DataParsoid; |
| 10 | use Wikimedia\Parsoid\Utils\DOMCompat; |
| 11 | use Wikimedia\Parsoid\Utils\DOMUtils; |
| 12 | |
| 13 | /** |
| 14 | * An external link, like `[http://example.com]`. |
| 15 | */ |
| 16 | class ExtLinkText extends ConstrainedText { |
| 17 | /** |
| 18 | * @param string $text |
| 19 | * @param Element $node |
| 20 | * @param SiteConfig $siteConfig |
| 21 | * @param string $type |
| 22 | * The type of the link, as described by the `rel` attribute. |
| 23 | */ |
| 24 | public function __construct( |
| 25 | string $text, Element $node, |
| 26 | SiteConfig $siteConfig, string $type |
| 27 | ) { |
| 28 | parent::__construct( [ |
| 29 | 'text' => $text, |
| 30 | 'node' => $node |
| 31 | ] |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | protected static function fromSelSerImpl( |
| 36 | string $text, Element $node, DataParsoid $dataParsoid, |
| 37 | Env $env, array $opts |
| 38 | ): ?ExtLinkText { |
| 39 | $stx = $dataParsoid->stx ?? ''; |
| 40 | if ( DOMUtils::hasRel( $node, 'mw:ExtLink' ) && |
| 41 | !in_array( $stx, [ 'simple', 'piped' ], true ) |
| 42 | ) { |
| 43 | $rel = DOMCompat::getAttribute( $node, 'rel' ); |
| 44 | return new ExtLinkText( $text, $node, $env->getSiteConfig(), $rel ); |
| 45 | } |
| 46 | return null; |
| 47 | } |
| 48 | } |