first commit - working
This commit is contained in:
23
vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php
vendored
Normal file
23
vendor/phar-io/version/src/constraints/AbstractVersionConstraint.php
vendored
Normal file
@ -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
vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php
vendored
Normal file
34
vendor/phar-io/version/src/constraints/AndVersionConstraintGroup.php
vendored
Normal file
@ -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
vendor/phar-io/version/src/constraints/AnyVersionConstraint.php
vendored
Normal file
20
vendor/phar-io/version/src/constraints/AnyVersionConstraint.php
vendored
Normal file
@ -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 '*';
|
||||
}
|
||||
}
|
16
vendor/phar-io/version/src/constraints/ExactVersionConstraint.php
vendored
Normal file
16
vendor/phar-io/version/src/constraints/ExactVersionConstraint.php
vendored
Normal file
@ -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;
|
||||
|
||||
class ExactVersionConstraint extends AbstractVersionConstraint {
|
||||
public function complies(Version $version): bool {
|
||||
return $this->asString() === $version->getVersionString();
|
||||
}
|
||||
}
|
26
vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php
vendored
Normal file
26
vendor/phar-io/version/src/constraints/GreaterThanOrEqualToVersionConstraint.php
vendored
Normal file
@ -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
vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php
vendored
Normal file
35
vendor/phar-io/version/src/constraints/OrVersionConstraintGroup.php
vendored
Normal file
@ -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
vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php
vendored
Normal file
33
vendor/phar-io/version/src/constraints/SpecificMajorAndMinorVersionConstraint.php
vendored
Normal file
@ -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;
|
||||
}
|
||||
}
|
25
vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php
vendored
Normal file
25
vendor/phar-io/version/src/constraints/SpecificMajorVersionConstraint.php
vendored
Normal file
@ -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
vendor/phar-io/version/src/constraints/VersionConstraint.php
vendored
Normal file
16
vendor/phar-io/version/src/constraints/VersionConstraint.php
vendored
Normal file
@ -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;
|
||||
}
|
Reference in New Issue
Block a user