mediatekformation

Version
in package

Facilitates the comparison of version strings.

Tags
author

Bernhard Schussek bschussek@gmail.com

Table of Contents

compare()  : bool
Compares two 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 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.

Examples:

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

Version::compare('1.2.3', '1.2.4', '==', 2)
// => true
Parameters
$version1 : string

A version string

$version2 : string

A version string to compare

$operator : string

The comparison operator

$precision : int|null = null

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

Tags
see
normalize()
Return values
bool

Whether the comparison succeeded

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

Examples:

Version::normalize('1.2.3', 1); // => '1'

Version::normalize('1.2.3', 2); // => '1.2'

Parameters
$version : string

A version string

$precision : int|null

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

Return values
string|null

the normalized version or NULL if it couldn't be normalized

__construct()

Must not be instantiated.

private __construct() : mixed
Return values
mixed

Search results