class Version

Class Version

Methods

static  bool
test( string $version, string $constraints, bool $strict = false, string $defaultComparison = '=')

Test if a version matched the version contraints.

static  array
parse( string $version = null)

Split a version into an associative array [version, major, minus, release, extra]

Details

at line 47
static bool test( string $version, string $constraints, bool $strict = false, string $defaultComparison = '=')

Test if a version matched the version contraints.

constraints can be simple or complex (multiple constraints separated by space) :

  • "~2.1" : version 2.1.*
  • "~2.1 <=2.1.4" : version 2.1.* but lower or equal to 2.1.4
  • ">=2.1" : version 2.1.*, 2.2, ...
  • ">2.1.1 <=2.1.5" : version greater than 2.1.1 but lower or equal than 2.1.5
  • ...

Parameters

string $version the version to test
string $constraints the versions constraints
bool $strict if true 2.1 is different of 2.1.0, if false version are normalized so 2.1 will be expended to 2.1.0
string $defaultComparison the default comparison if nothing provided

Return Value

bool true if version matches the constraints

at line 104
static array parse( string $version = null)

Split a version into an associative array [version, major, minus, release, extra]

Parameters

string $version the version to split

Return Value

array associative array [ 'version' => 'digit', 'major' => 'digit', 'minus' => 'digit', 'release' => 'digit', 'extra' => 'alphanumeric' ]