Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Selector.php

class Selector

Same name in this branch
  1. 11.1.x vendor/phpunit/php-code-coverage/src/Driver/Selector.php \SebastianBergmann\CodeCoverage\Driver\Selector

Selector class

@author Marco Marchiò <marco.mm89@gmail.com>

Hierarchy

  • class \Peast\Selector\Node\Selector

Expanded class hierarchy of Selector

1 file declares its use of Selector
PseudoSelector.php in vendor/mck89/peast/lib/Peast/Selector/Node/Part/PseudoSelector.php
1 string reference to 'Selector'
Parser::parseSimpleSelector in vendor/symfony/css-selector/Parser/Parser.php
Parses next simple node (hash, class, pseudo, negation).

File

vendor/mck89/peast/lib/Peast/Selector/Node/Selector.php, line 19

Namespace

Peast\Selector\Node
View source
class Selector {
    
    /**
     * Selector groups
     *
     * @var Group[]
     */
    protected $groups = array();
    
    /**
     * Adds a new group
     *
     * @param Group $group Group
     *
     * @return $this
     */
    public function addGroup(Group $group) {
        $this->groups[] = $group;
        return $this;
    }
    
    /**
     * Executes the current selector on the given matches
     *
     * @param Matches $matches Matches
     *
     * @return Matches
     */
    public function exec(Matches $matches) {
        $retMatches = array();
        foreach ($this->groups as $group) {
            $clonedMatches = $matches->createClone();
            $group->exec($clonedMatches);
            $retMatches[] = $clonedMatches;
        }
        if (count($retMatches) > 1) {
            $retMatches[0]->merge(array_slice($retMatches, 1));
        }
        return $retMatches[0];
    }

}

Members

Title Sort descending Modifiers Object type Summary
Selector::$groups protected property Selector groups
Selector::addGroup public function Adds a new group
Selector::exec public function Executes the current selector on the given matches
RSS feed
Powered by Drupal