BundledComponentCollection.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php declare(strict_types = 1);
  2. /*
  3. * This file is part of PharIo\Manifest.
  4. *
  5. * Copyright (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de> and contributors
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. *
  10. */
  11. namespace PharIo\Manifest;
  12. use Countable;
  13. use IteratorAggregate;
  14. use function count;
  15. /** @template-implements IteratorAggregate<int,BundledComponent> */
  16. class BundledComponentCollection implements Countable, IteratorAggregate {
  17. /** @var BundledComponent[] */
  18. private $bundledComponents = [];
  19. public function add(BundledComponent $bundledComponent): void {
  20. $this->bundledComponents[] = $bundledComponent;
  21. }
  22. /**
  23. * @return BundledComponent[]
  24. */
  25. public function getBundledComponents(): array {
  26. return $this->bundledComponents;
  27. }
  28. public function count(): int {
  29. return count($this->bundledComponents);
  30. }
  31. public function getIterator(): BundledComponentCollectionIterator {
  32. return new BundledComponentCollectionIterator($this);
  33. }
  34. }