SpecificConstraint.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Package\LinkConstraint;
  12. /**
  13. * Provides a common basis for specific package link constraints
  14. *
  15. * @author Nils Adermann <naderman@naderman.de>
  16. */
  17. abstract class SpecificConstraint implements LinkConstraintInterface
  18. {
  19. public function matches(LinkConstraintInterface $provider)
  20. {
  21. if ($provider instanceof MultiConstraint) {
  22. // turn matching around to find a match
  23. return $provider->matches($this);
  24. } elseif ($provider instanceof $this) {
  25. return $this->matchSpecific($provider);
  26. }
  27. return true;
  28. }
  29. // implementations must implement a method of this format:
  30. // not declared abstract here because type hinting violates parameter coherence (TODO right word?)
  31. // public function matchSpecific(<SpecificConstraintType> $provider);
  32. }