for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Cycle\ORM\Select\Scope;
use Cycle\ORM\Select\QueryBuilder;
use Cycle\ORM\Select\ScopeInterface;
/**
* Class ScopeAggregate.
*
* @implements \IteratorAggregate<ScopeInterface>
*/
final class ScopeAggregate implements ScopeInterface, \IteratorAggregate
{
* @var ScopeInterface[]
private $scopes = [];
public function __construct(ScopeInterface ...$scopes)
foreach ($scopes as $scope) {
$this->add($scope);
}
public function add(ScopeInterface $scope): void
if ($scope instanceof self) {
foreach ($scope as $s) {
$this->add($s);
$this->scopes[] = $scope;
* @inheritDoc
public function apply(QueryBuilder $query): void
foreach ($this->scopes as $scope) {
$scope->apply($query);
* @return \Traversable<ScopeInterface>
public function getIterator(): \Traversable
return new \ArrayIterator($this->scopes);