function Bound::compareTo
Compares a bound to another with a given operator.
Parameters
Bound $other:
string $operator:
Return value
bool
File
-
vendor/
composer/ semver/ src/ Constraint/ Bound.php, line 76
Class
Namespace
Composer\Semver\ConstraintCode
public function compareTo(Bound $other, $operator) {
if (!\in_array($operator, array(
'<',
'>',
), true)) {
throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
}
// If they are the same it doesn't matter
if ($this == $other) {
return false;
}
$compareResult = version_compare($this->getVersion(), $other->getVersion());
// Not the same version means we don't need to check if the bounds are inclusive or not
if (0 !== $compareResult) {
return ('>' === $operator ? 1 : -1) === $compareResult;
}
// Question we're answering here is "am I higher than $other?"
return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
}