Documentation

IcuVersion
in package

Facilitates the comparison of ICU version strings.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

Methods

compare()  : bool
Compares two ICU versions with an operator.
normalize()  : string|null
Normalizes a version string to the number of components given in the parameter $precision.
__construct()  : mixed
Must not be instantiated.

Methods

compare()

Compares two ICU versions with an operator.

public static compare(string $version1, string $version2, string $operator[, int|null $precision = null ]) : bool

This method is identical to , except that you can pass the number of regarded version components in the last argument $precision.

Also, a single digit release version and a single digit major version are contracted to a two digit release version. If no major version is given, it is substituted by zero.

Examples:

IcuVersion::compare('1.2.3', '1.2.4', '==')
// => false

IcuVersion::compare('1.2.3', '1.2.4', '==', 2)
// => true

IcuVersion::compare('1.2.3', '12.3', '==')
// => true

IcuVersion::compare('1', '10', '==')
// => true
Parameters
$version1 : string
$version2 : string
$operator : string
$precision : int|null = null

The number of components to compare. Pass NULL to compare the versions unchanged.

Tags
see
normalize()
Return values
bool

normalize()

Normalizes a version string to the number of components given in the parameter $precision.

public static normalize(string $version, int|null $precision) : string|null

A single digit release version and a single digit major version are contracted to a two digit release version. If no major version is given, it is substituted by zero.

Examples:

IcuVersion::normalize('1.2.3.4');
// => '12.3.4'

IcuVersion::normalize('1.2.3.4', 1);
// => '12'

IcuVersion::normalize('1.2.3.4', 2);
// => '12.3'
Parameters
$version : string
$precision : int|null

The number of components to include. Pass NULL to return the version unchanged.

Return values
string|null

__construct()

Must not be instantiated.

private __construct() : mixed

        
On this page

Search results