summaryrefslogtreecommitdiff
path: root/vendor/phar-io/version/src
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/phar-io/version/src')
-rw-r--r--vendor/phar-io/version/src/BuildMetaData.php28
-rw-r--r--vendor/phar-io/version/src/PreReleaseSuffix.php82
-rw-r--r--vendor/phar-io/version/src/Version.php208
-rw-r--r--vendor/phar-io/version/src/VersionConstraintParser.php115
-rw-r--r--vendor/phar-io/version/src/VersionConstraintValue.php88
-rw-r--r--vendor/phar-io/version/src/VersionNumber.php28
-rw-r--r--vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php23
-rw-r--r--vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php34
-rw-r--r--vendor/phar-io/version/src/constraints/AnyVersionConstraint.php20
-rw-r--r--vendor/phar-io/version/src/constraints/ExactVersionConstraint.php22
-rw-r--r--vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php26
-rw-r--r--vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php35
-rw-r--r--vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php33
-rw-r--r--vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php25
-rw-r--r--vendor/phar-io/version/src/constraints/VersionConstraint.php16
-rw-r--r--vendor/phar-io/version/src/exceptions/Exception.php15
-rw-r--r--vendor/phar-io/version/src/exceptions/InvalidPreReleaseSuffixException.php5
-rw-r--r--vendor/phar-io/version/src/exceptions/InvalidVersionException.php5
-rw-r--r--vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php5
-rw-r--r--vendor/phar-io/version/src/exceptions/NoPreReleaseSuffixException.php5
-rw-r--r--vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php13
21 files changed, 831 insertions, 0 deletions
diff --git a/vendor/phar-io/version/src/BuildMetaData.php b/vendor/phar-io/version/src/BuildMetaData.php
new file mode 100644
index 000000000..d42f0363f
--- /dev/null
+++ b/vendor/phar-io/version/src/BuildMetaData.php
@@ -0,0 +1,28 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class BuildMetaData {
+
+ /** @var string */
+ private $value;
+
+ public function __construct(string $value) {
+ $this->value = $value;
+ }
+
+ public function asString(): string {
+ return $this->value;
+ }
+
+ public function equals(BuildMetaData $other): bool {
+ return $this->asString() === $other->asString();
+ }
+}
diff --git a/vendor/phar-io/version/src/PreReleaseSuffix.php b/vendor/phar-io/version/src/PreReleaseSuffix.php
new file mode 100644
index 000000000..00563008e
--- /dev/null
+++ b/vendor/phar-io/version/src/PreReleaseSuffix.php
@@ -0,0 +1,82 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class PreReleaseSuffix {
+ private const valueScoreMap = [
+ 'dev' => 0,
+ 'a' => 1,
+ 'alpha' => 1,
+ 'b' => 2,
+ 'beta' => 2,
+ 'rc' => 3,
+ 'p' => 4,
+ 'pl' => 4,
+ 'patch' => 4,
+ ];
+
+ /** @var string */
+ private $value;
+
+ /** @var int */
+ private $valueScore;
+
+ /** @var int */
+ private $number = 0;
+
+ /** @var string */
+ private $full;
+
+ /**
+ * @throws InvalidPreReleaseSuffixException
+ */
+ public function __construct(string $value) {
+ $this->parseValue($value);
+ }
+
+ public function asString(): string {
+ return $this->full;
+ }
+
+ public function getValue(): string {
+ return $this->value;
+ }
+
+ public function getNumber(): ?int {
+ return $this->number;
+ }
+
+ public function isGreaterThan(PreReleaseSuffix $suffix): bool {
+ if ($this->valueScore > $suffix->valueScore) {
+ return true;
+ }
+
+ if ($this->valueScore < $suffix->valueScore) {
+ return false;
+ }
+
+ return $this->getNumber() > $suffix->getNumber();
+ }
+
+ private function mapValueToScore(string $value): int {
+ $value = \strtolower($value);
+
+ return self::valueScoreMap[$value];
+ }
+
+ private function parseValue(string $value): void {
+ $regex = '/-?((dev|beta|b|rc|alpha|a|patch|p|pl)\.?(\d*)).*$/i';
+
+ if (\preg_match($regex, $value, $matches) !== 1) {
+ throw new InvalidPreReleaseSuffixException(\sprintf('Invalid label %s', $value));
+ }
+
+ $this->full = $matches[1];
+ $this->value = $matches[2];
+
+ if ($matches[3] !== '') {
+ $this->number = (int)$matches[3];
+ }
+
+ $this->valueScore = $this->mapValueToScore($matches[2]);
+ }
+}
diff --git a/vendor/phar-io/version/src/Version.php b/vendor/phar-io/version/src/Version.php
new file mode 100644
index 000000000..644af5ca8
--- /dev/null
+++ b/vendor/phar-io/version/src/Version.php
@@ -0,0 +1,208 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class Version {
+ /** @var string */
+ private $originalVersionString;
+
+ /** @var VersionNumber */
+ private $major;
+
+ /** @var VersionNumber */
+ private $minor;
+
+ /** @var VersionNumber */
+ private $patch;
+
+ /** @var null|PreReleaseSuffix */
+ private $preReleaseSuffix;
+
+ /** @var null|BuildMetaData */
+ private $buildMetadata;
+
+ public function __construct(string $versionString) {
+ $this->ensureVersionStringIsValid($versionString);
+ $this->originalVersionString = $versionString;
+ }
+
+ /**
+ * @throws NoPreReleaseSuffixException
+ */
+ public function getPreReleaseSuffix(): PreReleaseSuffix {
+ if ($this->preReleaseSuffix === null) {
+ throw new NoPreReleaseSuffixException('No pre-release suffix set');
+ }
+
+ return $this->preReleaseSuffix;
+ }
+
+ public function getOriginalString(): string {
+ return $this->originalVersionString;
+ }
+
+ public function getVersionString(): string {
+ $str = \sprintf(
+ '%d.%d.%d',
+ $this->getMajor()->getValue() ?? 0,
+ $this->getMinor()->getValue() ?? 0,
+ $this->getPatch()->getValue() ?? 0
+ );
+
+ if (!$this->hasPreReleaseSuffix()) {
+ return $str;
+ }
+
+ return $str . '-' . $this->getPreReleaseSuffix()->asString();
+ }
+
+ public function hasPreReleaseSuffix(): bool {
+ return $this->preReleaseSuffix !== null;
+ }
+
+ public function equals(Version $other): bool {
+ if ($this->getVersionString() !== $other->getVersionString()) {
+ return false;
+ }
+
+ if ($this->hasBuildMetaData() !== $other->hasBuildMetaData()) {
+ return false;
+ }
+
+ if ($this->hasBuildMetaData() && $other->hasBuildMetaData() &&
+ !$this->getBuildMetaData()->equals($other->getBuildMetaData())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public function isGreaterThan(Version $version): bool {
+ if ($version->getMajor()->getValue() > $this->getMajor()->getValue()) {
+ return false;
+ }
+
+ if ($version->getMajor()->getValue() < $this->getMajor()->getValue()) {
+ return true;
+ }
+
+ if ($version->getMinor()->getValue() > $this->getMinor()->getValue()) {
+ return false;
+ }
+
+ if ($version->getMinor()->getValue() < $this->getMinor()->getValue()) {
+ return true;
+ }
+
+ if ($version->getPatch()->getValue() > $this->getPatch()->getValue()) {
+ return false;
+ }
+
+ if ($version->getPatch()->getValue() < $this->getPatch()->getValue()) {
+ return true;
+ }
+
+ if (!$version->hasPreReleaseSuffix() && !$this->hasPreReleaseSuffix()) {
+ return false;
+ }
+
+ if ($version->hasPreReleaseSuffix() && !$this->hasPreReleaseSuffix()) {
+ return true;
+ }
+
+ if (!$version->hasPreReleaseSuffix() && $this->hasPreReleaseSuffix()) {
+ return false;
+ }
+
+ return $this->getPreReleaseSuffix()->isGreaterThan($version->getPreReleaseSuffix());
+ }
+
+ public function getMajor(): VersionNumber {
+ return $this->major;
+ }
+
+ public function getMinor(): VersionNumber {
+ return $this->minor;
+ }
+
+ public function getPatch(): VersionNumber {
+ return $this->patch;
+ }
+
+ /**
+ * @psalm-assert-if-true BuildMetaData $this->buildMetadata
+ * @psalm-assert-if-true BuildMetaData $this->getBuildMetaData()
+ */
+ public function hasBuildMetaData(): bool {
+ return $this->buildMetadata !== null;
+ }
+
+ /**
+ * @throws NoBuildMetaDataException
+ */
+ public function getBuildMetaData(): BuildMetaData {
+ if (!$this->hasBuildMetaData()) {
+ throw new NoBuildMetaDataException('No build metadata set');
+ }
+
+ return $this->buildMetadata;
+ }
+
+ /**
+ * @param string[] $matches
+ *
+ * @throws InvalidPreReleaseSuffixException
+ */
+ private function parseVersion(array $matches): void {
+ $this->major = new VersionNumber((int)$matches['Major']);
+ $this->minor = new VersionNumber((int)$matches['Minor']);
+ $this->patch = isset($matches['Patch']) ? new VersionNumber((int)$matches['Patch']) : new VersionNumber(0);
+
+ if (isset($matches['PreReleaseSuffix']) && $matches['PreReleaseSuffix'] !== '') {
+ $this->preReleaseSuffix = new PreReleaseSuffix($matches['PreReleaseSuffix']);
+ }
+
+ if (isset($matches['BuildMetadata'])) {
+ $this->buildMetadata = new BuildMetaData($matches['BuildMetadata']);
+ }
+ }
+
+ /**
+ * @param string $version
+ *
+ * @throws InvalidVersionException
+ */
+ private function ensureVersionStringIsValid($version): void {
+ $regex = '/^v?
+ (?P<Major>0|[1-9]\d*)
+ \\.
+ (?P<Minor>0|[1-9]\d*)
+ (\\.
+ (?P<Patch>0|[1-9]\d*)
+ )?
+ (?:
+ -
+ (?<PreReleaseSuffix>(?:(dev|beta|b|rc|alpha|a|patch|p|pl)\.?\d*))
+ )?
+ (?:
+ \\+
+ (?P<BuildMetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-@]+)*)
+ )?
+ $/xi';
+
+ if (\preg_match($regex, $version, $matches) !== 1) {
+ throw new InvalidVersionException(
+ \sprintf("Version string '%s' does not follow SemVer semantics", $version)
+ );
+ }
+
+ $this->parseVersion($matches);
+ }
+}
diff --git a/vendor/phar-io/version/src/VersionConstraintParser.php b/vendor/phar-io/version/src/VersionConstraintParser.php
new file mode 100644
index 000000000..03d6a0959
--- /dev/null
+++ b/vendor/phar-io/version/src/VersionConstraintParser.php
@@ -0,0 +1,115 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class VersionConstraintParser {
+ /**
+ * @throws UnsupportedVersionConstraintException
+ */
+ public function parse(string $value): VersionConstraint {
+ if (\strpos($value, '|') !== false) {
+ return $this->handleOrGroup($value);
+ }
+
+ if (!\preg_match('/^[\^~*]?v?[\d.*]+(?:-.*)?$/i', $value)) {
+ throw new UnsupportedVersionConstraintException(
+ \sprintf('Version constraint %s is not supported.', $value)
+ );
+ }
+
+ switch ($value[0]) {
+ case '~':
+ return $this->handleTildeOperator($value);
+ case '^':
+ return $this->handleCaretOperator($value);
+ }
+
+ $constraint = new VersionConstraintValue($value);
+
+ if ($constraint->getMajor()->isAny()) {
+ return new AnyVersionConstraint();
+ }
+
+ if ($constraint->getMinor()->isAny()) {
+ return new SpecificMajorVersionConstraint(
+ $constraint->getVersionString(),
+ $constraint->getMajor()->getValue() ?? 0
+ );
+ }
+
+ if ($constraint->getPatch()->isAny()) {
+ return new SpecificMajorAndMinorVersionConstraint(
+ $constraint->getVersionString(),
+ $constraint->getMajor()->getValue() ?? 0,
+ $constraint->getMinor()->getValue() ?? 0
+ );
+ }
+
+ return new ExactVersionConstraint($constraint->getVersionString());
+ }
+
+ private function handleOrGroup(string $value): OrVersionConstraintGroup {
+ $constraints = [];
+
+ foreach (\preg_split('{\s*\|\|?\s*}', \trim($value)) as $groupSegment) {
+ $constraints[] = $this->parse(\trim($groupSegment));
+ }
+
+ return new OrVersionConstraintGroup($value, $constraints);
+ }
+
+ private function handleTildeOperator(string $value): AndVersionConstraintGroup {
+ $constraintValue = new VersionConstraintValue(\substr($value, 1));
+
+ if ($constraintValue->getPatch()->isAny()) {
+ return $this->handleCaretOperator($value);
+ }
+
+ $constraints = [
+ new GreaterThanOrEqualToVersionConstraint(
+ $value,
+ new Version(\substr($value, 1))
+ ),
+ new SpecificMajorAndMinorVersionConstraint(
+ $value,
+ $constraintValue->getMajor()->getValue() ?? 0,
+ $constraintValue->getMinor()->getValue() ?? 0
+ )
+ ];
+
+ return new AndVersionConstraintGroup($value, $constraints);
+ }
+
+ private function handleCaretOperator(string $value): AndVersionConstraintGroup {
+ $constraintValue = new VersionConstraintValue(\substr($value, 1));
+
+ $constraints = [
+ new GreaterThanOrEqualToVersionConstraint($value, new Version(\substr($value, 1)))
+ ];
+
+ if ($constraintValue->getMajor()->getValue() === 0) {
+ $constraints[] = new SpecificMajorAndMinorVersionConstraint(
+ $value,
+ $constraintValue->getMajor()->getValue() ?? 0,
+ $constraintValue->getMinor()->getValue() ?? 0
+ );
+ } else {
+ $constraints[] = new SpecificMajorVersionConstraint(
+ $value,
+ $constraintValue->getMajor()->getValue() ?? 0
+ );
+ }
+
+ return new AndVersionConstraintGroup(
+ $value,
+ $constraints
+ );
+ }
+}
diff --git a/vendor/phar-io/version/src/VersionConstraintValue.php b/vendor/phar-io/version/src/VersionConstraintValue.php
new file mode 100644
index 000000000..0762e7c0e
--- /dev/null
+++ b/vendor/phar-io/version/src/VersionConstraintValue.php
@@ -0,0 +1,88 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class VersionConstraintValue {
+ /** @var VersionNumber */
+ private $major;
+
+ /** @var VersionNumber */
+ private $minor;
+
+ /** @var VersionNumber */
+ private $patch;
+
+ /** @var string */
+ private $label = '';
+
+ /** @var string */
+ private $buildMetaData = '';
+
+ /** @var string */
+ private $versionString = '';
+
+ public function __construct(string $versionString) {
+ $this->versionString = $versionString;
+
+ $this->parseVersion($versionString);
+ }
+
+ public function getLabel(): string {
+ return $this->label;
+ }
+
+ public function getBuildMetaData(): string {
+ return $this->buildMetaData;
+ }
+
+ public function getVersionString(): string {
+ return $this->versionString;
+ }
+
+ public function getMajor(): VersionNumber {
+ return $this->major;
+ }
+
+ public function getMinor(): VersionNumber {
+ return $this->minor;
+ }
+
+ public function getPatch(): VersionNumber {
+ return $this->patch;
+ }
+
+ private function parseVersion(string $versionString): void {
+ $this->extractBuildMetaData($versionString);
+ $this->extractLabel($versionString);
+ $this->stripPotentialVPrefix($versionString);
+
+ $versionSegments = \explode('.', $versionString);
+ $this->major = new VersionNumber(\is_numeric($versionSegments[0]) ? (int)$versionSegments[0] : null);
+
+ $minorValue = isset($versionSegments[1]) && \is_numeric($versionSegments[1]) ? (int)$versionSegments[1] : null;
+ $patchValue = isset($versionSegments[2]) && \is_numeric($versionSegments[2]) ? (int)$versionSegments[2] : null;
+
+ $this->minor = new VersionNumber($minorValue);
+ $this->patch = new VersionNumber($patchValue);
+ }
+
+ private function extractBuildMetaData(string &$versionString): void {
+ if (\preg_match('/\+(.*)/', $versionString, $matches) === 1) {
+ $this->buildMetaData = $matches[1];
+ $versionString = \str_replace($matches[0], '', $versionString);
+ }
+ }
+
+ private function extractLabel(string &$versionString): void {
+ if (\preg_match('/-(.*)/', $versionString, $matches) === 1) {
+ $this->label = $matches[1];
+ $versionString = \str_replace($matches[0], '', $versionString);
+ }
+ }
+
+ private function stripPotentialVPrefix(string &$versionString): void {
+ if ($versionString[0] !== 'v') {
+ return;
+ }
+ $versionString = \substr($versionString, 1);
+ }
+}
diff --git a/vendor/phar-io/version/src/VersionNumber.php b/vendor/phar-io/version/src/VersionNumber.php
new file mode 100644
index 000000000..4833a9b0f
--- /dev/null
+++ b/vendor/phar-io/version/src/VersionNumber.php
@@ -0,0 +1,28 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class VersionNumber {
+
+ /** @var ?int */
+ private $value;
+
+ public function __construct(?int $value) {
+ $this->value = $value;
+ }
+
+ public function isAny(): bool {
+ return $this->value === null;
+ }
+
+ public function getValue(): ?int {
+ return $this->value;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php b/vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php
new file mode 100644
index 000000000..66201a140
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php
@@ -0,0 +1,23 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+abstract class AbstractVersionConstraint implements VersionConstraint {
+ /** @var string */
+ private $originalValue;
+
+ public function __construct(string $originalValue) {
+ $this->originalValue = $originalValue;
+ }
+
+ public function asString(): string {
+ return $this->originalValue;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php b/vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php
new file mode 100644
index 000000000..5096f2fbb
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php
@@ -0,0 +1,34 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class AndVersionConstraintGroup extends AbstractVersionConstraint {
+ /** @var VersionConstraint[] */
+ private $constraints = [];
+
+ /**
+ * @param VersionConstraint[] $constraints
+ */
+ public function __construct(string $originalValue, array $constraints) {
+ parent::__construct($originalValue);
+
+ $this->constraints = $constraints;
+ }
+
+ public function complies(Version $version): bool {
+ foreach ($this->constraints as $constraint) {
+ if (!$constraint->complies($version)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/AnyVersionConstraint.php b/vendor/phar-io/version/src/constraints/AnyVersionConstraint.php
new file mode 100644
index 000000000..1499f071f
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/AnyVersionConstraint.php
@@ -0,0 +1,20 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class AnyVersionConstraint implements VersionConstraint {
+ public function complies(Version $version): bool {
+ return true;
+ }
+
+ public function asString(): string {
+ return '*';
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/ExactVersionConstraint.php b/vendor/phar-io/version/src/constraints/ExactVersionConstraint.php
new file mode 100644
index 000000000..1d675c9c9
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/ExactVersionConstraint.php
@@ -0,0 +1,22 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class ExactVersionConstraint extends AbstractVersionConstraint {
+ public function complies(Version $version): bool {
+ $other = $version->getVersionString();
+
+ if ($version->hasBuildMetaData()) {
+ $other .= '+' . $version->getBuildMetaData()->asString();
+ }
+
+ return $this->asString() === $other;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php b/vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php
new file mode 100644
index 000000000..ec3717231
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php
@@ -0,0 +1,26 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class GreaterThanOrEqualToVersionConstraint extends AbstractVersionConstraint {
+ /** @var Version */
+ private $minimalVersion;
+
+ public function __construct(string $originalValue, Version $minimalVersion) {
+ parent::__construct($originalValue);
+
+ $this->minimalVersion = $minimalVersion;
+ }
+
+ public function complies(Version $version): bool {
+ return $version->getVersionString() === $this->minimalVersion->getVersionString()
+ || $version->isGreaterThan($this->minimalVersion);
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php b/vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php
new file mode 100644
index 000000000..59fd382f8
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php
@@ -0,0 +1,35 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class OrVersionConstraintGroup extends AbstractVersionConstraint {
+ /** @var VersionConstraint[] */
+ private $constraints = [];
+
+ /**
+ * @param string $originalValue
+ * @param VersionConstraint[] $constraints
+ */
+ public function __construct($originalValue, array $constraints) {
+ parent::__construct($originalValue);
+
+ $this->constraints = $constraints;
+ }
+
+ public function complies(Version $version): bool {
+ foreach ($this->constraints as $constraint) {
+ if ($constraint->complies($version)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php b/vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php
new file mode 100644
index 000000000..302aa311c
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php
@@ -0,0 +1,33 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class SpecificMajorAndMinorVersionConstraint extends AbstractVersionConstraint {
+ /** @var int */
+ private $major;
+
+ /** @var int */
+ private $minor;
+
+ public function __construct(string $originalValue, int $major, int $minor) {
+ parent::__construct($originalValue);
+
+ $this->major = $major;
+ $this->minor = $minor;
+ }
+
+ public function complies(Version $version): bool {
+ if ($version->getMajor()->getValue() !== $this->major) {
+ return false;
+ }
+
+ return $version->getMinor()->getValue() === $this->minor;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php b/vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php
new file mode 100644
index 000000000..968b809c1
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php
@@ -0,0 +1,25 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+class SpecificMajorVersionConstraint extends AbstractVersionConstraint {
+ /** @var int */
+ private $major;
+
+ public function __construct(string $originalValue, int $major) {
+ parent::__construct($originalValue);
+
+ $this->major = $major;
+ }
+
+ public function complies(Version $version): bool {
+ return $version->getMajor()->getValue() === $this->major;
+ }
+}
diff --git a/vendor/phar-io/version/src/constraints/VersionConstraint.php b/vendor/phar-io/version/src/constraints/VersionConstraint.php
new file mode 100644
index 000000000..e94f9e00e
--- /dev/null
+++ b/vendor/phar-io/version/src/constraints/VersionConstraint.php
@@ -0,0 +1,16 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+interface VersionConstraint {
+ public function complies(Version $version): bool;
+
+ public function asString(): string;
+}
diff --git a/vendor/phar-io/version/src/exceptions/Exception.php b/vendor/phar-io/version/src/exceptions/Exception.php
new file mode 100644
index 000000000..3ea458f3d
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/Exception.php
@@ -0,0 +1,15 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+use Throwable;
+
+interface Exception extends Throwable {
+}
diff --git a/vendor/phar-io/version/src/exceptions/InvalidPreReleaseSuffixException.php b/vendor/phar-io/version/src/exceptions/InvalidPreReleaseSuffixException.php
new file mode 100644
index 000000000..bc0b0c3e4
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/InvalidPreReleaseSuffixException.php
@@ -0,0 +1,5 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class InvalidPreReleaseSuffixException extends \Exception implements Exception {
+}
diff --git a/vendor/phar-io/version/src/exceptions/InvalidVersionException.php b/vendor/phar-io/version/src/exceptions/InvalidVersionException.php
new file mode 100644
index 000000000..e9e93108c
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/InvalidVersionException.php
@@ -0,0 +1,5 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class InvalidVersionException extends \InvalidArgumentException implements Exception {
+}
diff --git a/vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php b/vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php
new file mode 100644
index 000000000..09e9bee0d
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/NoBuildMetaDataException.php
@@ -0,0 +1,5 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class NoBuildMetaDataException extends \Exception implements Exception {
+}
diff --git a/vendor/phar-io/version/src/exceptions/NoPreReleaseSuffixException.php b/vendor/phar-io/version/src/exceptions/NoPreReleaseSuffixException.php
new file mode 100644
index 000000000..aa0b20f7a
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/NoPreReleaseSuffixException.php
@@ -0,0 +1,5 @@
+<?php declare(strict_types = 1);
+namespace PharIo\Version;
+
+class NoPreReleaseSuffixException extends \Exception implements Exception {
+}
diff --git a/vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php b/vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php
new file mode 100644
index 000000000..6d98e8250
--- /dev/null
+++ b/vendor/phar-io/version/src/exceptions/UnsupportedVersionConstraintException.php
@@ -0,0 +1,13 @@
+<?php declare(strict_types = 1);
+/*
+ * This file is part of PharIo\Version.
+ *
+ * (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]>, Sebastian Bergmann <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PharIo\Version;
+
+final class UnsupportedVersionConstraintException extends \RuntimeException implements Exception {
+}