VersionComparator

class to compare version numbers. it supports the following keywords: "pre", "-dev", "b", "beta", "a", "alpha".

It supports also the "*" wilcard. This wilcard must be the last part of the version number.

package

Default

Methods

Compare two version objects.

compare(\Jelix\Version\Version $version1, \Jelix\Version\Version $version2) : integer
static

Arguments

Response

integer

  • 0 if versions are equals
    • -1 if $version1 is lower than $version2
    • 1 if $version1 is higher than $version2

Compare two version as string.

compareVersion(string $version1, string $version2) : integer
static

It supports wildcard in one of the version

Arguments

$version1

string

$version2

string

Response

integer

0 if equal, -1 if $version1 < $version2, 1 if $version1 > $version2

compareVersionRange

compareVersionRange(string $version, string $range) : boolean
static

Arguments

$version

string

a version number

$range

string

a version expression respecting Composer range syntax

Response

boolean

true if the given version match the given range

compileRange

compileRange( $range) : \Jelix\Version\VersionRangeOperatorInterface
static

normalizeVersionNumber

normalizeVersionNumber( &$n) 
static

Arguments

$n

create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.

serializeVersion( $version, integer $starReplacement,  $pad = 4) 
static

It doesn't support all version notation. Use serializeVersion2 instead.

deprecated

Arguments

$version

$starReplacement

integer

1 if it should replace by max value, 0 for min value

$pad

create a string representing a version number in a manner that it could be easily to be compared with an other serialized version. useful to do comparison in a database for example.

serializeVersion2( $version, integer $starReplacement,  $maxpad = 10) 
static

Arguments

$version

$starReplacement

integer

1 if it should replace '*' by max value, 0 for min value

$maxpad