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

Breadcrumb

  1. Drupal Core 11.1.x

Selector.php

Same filename in this branch
  1. 11.1.x vendor/phpunit/php-code-coverage/src/Driver/Selector.php

Namespace

Peast\Selector\Node

File

vendor/mck89/peast/lib/Peast/Selector/Node/Selector.php

View source
<?php


/**
 * This file is part of the Peast package
 *
 * (c) Marco Marchiò <marco.mm89@gmail.com>
 *
 * For the full copyright and license information refer to the LICENSE file
 * distributed with this source code
 */
namespace Peast\Selector\Node;

use Peast\Selector\Matches;

/**
 * Selector class
 * 
 * @author Marco Marchiò <marco.mm89@gmail.com>
 */
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];
    }

}

Classes

Title Deprecated Summary
Selector Selector class

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal