AndVersionConstraintGroup.php 983 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php declare(strict_types = 1);
  2. /*
  3. * This file is part of PharIo\Version.
  4. *
  5. * (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PharIo\Version;
  11. class AndVersionConstraintGroup extends AbstractVersionConstraint {
  12. /** @var VersionConstraint[] */
  13. private $constraints = [];
  14. /**
  15. * @param VersionConstraint[] $constraints
  16. */
  17. public function __construct(string $originalValue, array $constraints) {
  18. parent::__construct($originalValue);
  19. $this->constraints = $constraints;
  20. }
  21. public function complies(Version $version): bool {
  22. foreach ($this->constraints as $constraint) {
  23. if (!$constraint->complies($version)) {
  24. return false;
  25. }
  26. }
  27. return true;
  28. }
  29. }