MatchAllConstraint.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. * This constraint matches everything.
  15. */
  16. class MatchAllConstraint implements ConstraintInterface
  17. {
  18. /** @var string|null */
  19. protected $prettyString;
  20. /**
  21. * @param ConstraintInterface $provider
  22. *
  23. * @return bool
  24. */
  25. public function matches(ConstraintInterface $provider)
  26. {
  27. return true;
  28. }
  29. /**
  30. * {@inheritDoc}
  31. */
  32. public function compile($otherOperator)
  33. {
  34. return 'true';
  35. }
  36. /**
  37. * {@inheritDoc}
  38. */
  39. public function setPrettyString($prettyString)
  40. {
  41. $this->prettyString = $prettyString;
  42. }
  43. /**
  44. * {@inheritDoc}
  45. */
  46. public function getPrettyString()
  47. {
  48. if ($this->prettyString) {
  49. return $this->prettyString;
  50. }
  51. return (string) $this;
  52. }
  53. /**
  54. * {@inheritDoc}
  55. */
  56. public function __toString()
  57. {
  58. return '*';
  59. }
  60. /**
  61. * {@inheritDoc}
  62. */
  63. public function getUpperBound()
  64. {
  65. return Bound::positiveInfinity();
  66. }
  67. /**
  68. * {@inheritDoc}
  69. */
  70. public function getLowerBound()
  71. {
  72. return Bound::zero();
  73. }
  74. }