| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file is part of the Peast package |
| 4 |
* |
| 5 |
* (c) Marco Marchiò <[email protected]> |
| 6 |
* |
| 7 |
* For the full copyright and license information refer to the LICENSE file |
| 8 |
* distributed with this source code |
| 9 |
*/ |
| 10 |
namespace Peast\Selector\Node; |
| 11 |
|
| 12 |
use Peast\Selector\Matches; |
| 13 |
|
| 14 |
/** |
| 15 |
* Selector group class |
| 16 |
* |
| 17 |
* @author Marco Marchiò <[email protected]> |
| 18 |
*/ |
| 19 |
class Group |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Selector combinators |
| 23 |
* |
| 24 |
* @var Combinator[] |
| 25 |
*/ |
| 26 |
protected $combinators = array(); |
| 27 |
|
| 28 |
/** |
| 29 |
* Adds a combinator |
| 30 |
* |
| 31 |
* @param Combinator $combinators Combinator |
| 32 |
* |
| 33 |
* @return $this |
| 34 |
*/ |
| 35 |
public function addCombinator(Combinator $combinators) |
| 36 |
{ |
| 37 |
$this->combinators[] = $combinators; |
| 38 |
return $this; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Executes the current group on the given matches |
| 43 |
* |
| 44 |
* @param Matches $matches Matches |
| 45 |
*/ |
| 46 |
public function exec(Matches $matches) |
| 47 |
{ |
| 48 |
foreach ($this->combinators as $combinator) { |
| 49 |
$combinator->exec($matches); |
| 50 |
} |
| 51 |
} |
| 52 |
} |