Intervals
in package
Helper class generating intervals from constraints
This contains utilities for:
-
compacting an existing constraint which can be used to combine several into one by creating a MultiConstraint out of the many constraints you have.
-
checking whether one subset is a subset of another.
Note: You should call clear to free memoization memory usage when you are done using this class
Table of Contents
Properties
- $intervalsCache : mixed
- $opSortOrder : mixed
Methods
- clear() : void
- Clears the memoization cache once you are done
- compactConstraint() : ConstraintInterface
- Attempts to optimize a MultiConstraint
- get() : array<string|int, mixed>
- Creates an array of numeric intervals and branch constraints representing a given constraint
- haveIntersections() : bool
- Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
- isSubsetOf() : bool
- Checks whether $candidate is a subset of $constraint
- generateIntervals() : mixed
- generateSingleConstraintIntervals() : mixed
Properties
$intervalsCache
private
static mixed
$intervalsCache
= array()
Tags
$opSortOrder
private
static mixed
$opSortOrder
= array('>=' => -3, '<' => -2, '>' => 2, '<=' => 3)
Tags
Methods
clear()
Clears the memoization cache once you are done
public
static clear() : void
compactConstraint()
Attempts to optimize a MultiConstraint
public
static compactConstraint(ConstraintInterface $constraint) : ConstraintInterface
When merging MultiConstraints together they can get very large, this will compact it by looking at the real intervals covered by all the constraints and then creates a new constraint containing only the smallest amount of rules to match the same intervals.
Parameters
- $constraint : ConstraintInterface
Return values
ConstraintInterfaceget()
Creates an array of numeric intervals and branch constraints representing a given constraint
public
static get(ConstraintInterface $constraint) : array<string|int, mixed>
if the returned numeric array is empty it means the constraint matches nothing in the numeric range (0 - +inf) if the returned branches array is empty it means no dev-* versions are matched if a constraint matches all possible dev-* versions, branches will contain Interval::anyDev()
Parameters
- $constraint : ConstraintInterface
Tags
Return values
array<string|int, mixed>haveIntersections()
Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
public
static haveIntersections(ConstraintInterface $a, ConstraintInterface $b) : bool
Parameters
- $a : ConstraintInterface
- $b : ConstraintInterface
Return values
boolisSubsetOf()
Checks whether $candidate is a subset of $constraint
public
static isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint) : bool
Parameters
- $candidate : ConstraintInterface
- $constraint : ConstraintInterface
Return values
boolgenerateIntervals()
private
static generateIntervals(ConstraintInterface $constraint[, bool $stopOnFirstValidInterval = false ]) : mixed
Parameters
- $constraint : ConstraintInterface
- $stopOnFirstValidInterval : bool = false
Tags
generateSingleConstraintIntervals()
private
static generateSingleConstraintIntervals(Constraint $constraint) : mixed
Parameters
- $constraint : Constraint