mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 11:11:31 +00:00
Build modified streamline images
The official image from streamline does not currently work for the arm64 platform. As a temporary measure, the source code and docker build scripts have been lifted from the official images and are used to build locally. Some additional modifications are made to reduce overall image size, these are documented in docker/README.md
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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 '*';
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Version;
|
||||
|
||||
class InvalidPreReleaseSuffixException extends \Exception implements Exception {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Version;
|
||||
|
||||
class InvalidVersionException extends \InvalidArgumentException implements Exception {
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Version;
|
||||
|
||||
class NoBuildMetaDataException extends \Exception implements Exception {
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
<?php declare(strict_types = 1);
|
||||
namespace PharIo\Version;
|
||||
|
||||
class NoPreReleaseSuffixException extends \Exception implements Exception {
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php declare(strict_types = 1);
|
||||
/*
|
||||
* This file is part of PharIo\Version.
|
||||
*
|
||||
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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 {
|
||||
}
|
||||
Reference in New Issue
Block a user