| Total Complexity | 8 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | final class ScopeAggregate implements ScopeInterface, \IteratorAggregate |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var ScopeInterface[] |
||
| 19 | */ |
||
| 20 | private $scopes = []; |
||
| 21 | |||
| 22 | public function __construct(ScopeInterface ...$scopes) |
||
| 23 | { |
||
| 24 | foreach ($scopes as $scope) { |
||
| 25 | $this->add($scope); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | public function add(ScopeInterface $scope): void |
||
| 30 | { |
||
| 31 | if ($scope instanceof self) { |
||
| 32 | foreach ($scope as $s) { |
||
| 33 | $this->add($s); |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | $this->scopes[] = $scope; |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @inheritDoc |
||
| 42 | */ |
||
| 43 | public function apply(QueryBuilder $query): void |
||
| 44 | { |
||
| 45 | foreach ($this->scopes as $scope) { |
||
| 46 | $scope->apply($query); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return \Traversable<ScopeInterface> |
||
| 52 | */ |
||
| 53 | public function getIterator(): \Traversable |
||
| 56 | } |
||
| 57 | } |
||
| 58 |