Constraint
1 year ago
Comparator.php
1 year ago
CompilingMatcher.php
1 year ago
Interval.php
1 year ago
Intervals.php
1 year ago
Semver.php
7 months ago
VersionParser.php
1 year ago
Interval.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of composer/semver. |
| 5 | * |
| 6 | * (c) Composer <https://github.com/composer> |
| 7 | * |
| 8 | * For the full copyright and license information, please view |
| 9 | * the LICENSE file that was distributed with this source code. |
| 10 | */ |
| 11 | |
| 12 | namespace Composer\Semver; |
| 13 | |
| 14 | use Composer\Semver\Constraint\Constraint; |
| 15 | |
| 16 | class Interval |
| 17 | { |
| 18 | /** @var Constraint */ |
| 19 | private $start; |
| 20 | /** @var Constraint */ |
| 21 | private $end; |
| 22 | |
| 23 | public function __construct(Constraint $start, Constraint $end) |
| 24 | { |
| 25 | $this->start = $start; |
| 26 | $this->end = $end; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @return Constraint |
| 31 | */ |
| 32 | public function getStart() |
| 33 | { |
| 34 | return $this->start; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @return Constraint |
| 39 | */ |
| 40 | public function getEnd() |
| 41 | { |
| 42 | return $this->end; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @return Constraint |
| 47 | */ |
| 48 | public static function fromZero() |
| 49 | { |
| 50 | static $zero; |
| 51 | |
| 52 | if (null === $zero) { |
| 53 | $zero = new Constraint('>=', '0.0.0.0-dev'); |
| 54 | } |
| 55 | |
| 56 | return $zero; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @return Constraint |
| 61 | */ |
| 62 | public static function untilPositiveInfinity() |
| 63 | { |
| 64 | static $positiveInfinity; |
| 65 | |
| 66 | if (null === $positiveInfinity) { |
| 67 | $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0'); |
| 68 | } |
| 69 | |
| 70 | return $positiveInfinity; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @return self |
| 75 | */ |
| 76 | public static function any() |
| 77 | { |
| 78 | return new self(self::fromZero(), self::untilPositiveInfinity()); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return array{'names': string[], 'exclude': bool} |
| 83 | */ |
| 84 | public static function anyDev() |
| 85 | { |
| 86 | // any == exclude nothing |
| 87 | return array('names' => array(), 'exclude' => true); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return array{'names': string[], 'exclude': bool} |
| 92 | */ |
| 93 | public static function noDev() |
| 94 | { |
| 95 | // nothing == no names included |
| 96 | return array('names' => array(), 'exclude' => false); |
| 97 | } |
| 98 | } |
| 99 |