ClassParser.php
2 years ago
ElementParser.php
2 years ago
EmptyStringParser.php
2 years ago
HashParser.php
2 years ago
index.php
2 years ago
ElementParser.php
23 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\Parser\Shortcut; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\CssSelector\Node\ElementNode; |
| 5 | use MailPoetVendor\Symfony\Component\CssSelector\Node\SelectorNode; |
| 6 | use MailPoetVendor\Symfony\Component\CssSelector\Parser\ParserInterface; |
| 7 | class ElementParser implements ParserInterface |
| 8 | { |
| 9 | public function parse(string $source) : array |
| 10 | { |
| 11 | // Matches an optional namespace, required element or `*` |
| 12 | // $source = 'testns|testel'; |
| 13 | // $matches = array (size=3) |
| 14 | // 0 => string 'testns|testel' (length=13) |
| 15 | // 1 => string 'testns' (length=6) |
| 16 | // 2 => string 'testel' (length=6) |
| 17 | if (\preg_match('/^(?:([a-z]++)\\|)?([\\w-]++|\\*)$/i', \trim($source), $matches)) { |
| 18 | return [new SelectorNode(new ElementNode($matches[1] ?: null, $matches[2]))]; |
| 19 | } |
| 20 | return []; |
| 21 | } |
| 22 | } |
| 23 |