EmptyConstraint.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /*
  3. * This file is part of composer/semver.
  4. *
  5. * (c) Composer <https://github.com/composer>
  6. *
  7. * For the full copyright and license information, please view
  8. * the LICENSE file that was distributed with this source code.
  9. */
  10. namespace Composer\Semver\Constraint;
  11. /**
  12. * Defines the absence of a constraint.
  13. */
  14. class EmptyConstraint implements ConstraintInterface
  15. {
  16. /** @var string */
  17. protected $prettyString;
  18. /**
  19. * @param ConstraintInterface $provider
  20. *
  21. * @return bool
  22. */
  23. public function matches(ConstraintInterface $provider)
  24. {
  25. return true;
  26. }
  27. /**
  28. * @param $prettyString
  29. */
  30. public function setPrettyString($prettyString)
  31. {
  32. $this->prettyString = $prettyString;
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getPrettyString()
  38. {
  39. if ($this->prettyString) {
  40. return $this->prettyString;
  41. }
  42. return (string) $this;
  43. }
  44. /**
  45. * @return string
  46. */
  47. public function __toString()
  48. {
  49. return '[]';
  50. }
  51. }