pQuery.php
24 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\Util\pQuery; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoetVendor\pQuery\pQuery as pQuerypQuery; |
| 9 | |
| 10 | // extend pQuery class to use UTF-8 encoding when getting elements' inner/outer text |
| 11 | // phpcs:ignore Squiz.Classes.ValidClassName |
| 12 | class pQuery extends pQuerypQuery { |
| 13 | public static function parseStr($html): DomNode { |
| 14 | $parser = new Html5Parser($html); |
| 15 | |
| 16 | if (!$parser->root instanceof DomNode) { |
| 17 | // this condition shouldn't happen it is here only for PHPStan |
| 18 | throw new \Exception('Renderer is not configured correctly'); |
| 19 | } |
| 20 | |
| 21 | return $parser->root; |
| 22 | } |
| 23 | } |
| 24 |