Version
About 1 min
Version
The version class
Handy for comparing version numbers such as 1.0 vs 1.3 or even 2.3.6 vs 1.6.3.7.32
Properties
default_delimiter
public string $default_delimiter
__precision
public int $__precision
__version
private string $__version
__version_parts
private array $__version_parts
Methods
__construct
Version constructor.
public __construct({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$version | string | string The version number as a string |
$precision | int | |
$delimiter | string |
__toString
Magic method to output the version as a string.
public __toString({Array})
format
public format({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$version | string | |
$precision | int | |
$delimiter | string |
set
Sets the version string and updates the version parts and precision.
public set({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$version | string | the version string to set |
$delimiter | string | The delimiter used in the version string. If null, the default delimiter is used. |
get
public get({Array})
getParts
Get the version parts as an array.
public getParts({Array})
compareTo
Compare the version to another version.
public compareTo({Array})
Returns an integer indicating the result:
- 0 Indicates the versions are equal.
- -1 Means the vesion is less than $that.
- 1 Means the version is greater than $that.
Parameters
Parameter | Type | Description |
---|---|---|
$that | Version | The version to compare against. Can be either a version string or another version object. |
$delimiter | string |
equals
Compares two versions to see if they are equal.
public equals({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$that | Version | The version to compare to |
setIfHigher
Sets the current version to the given version if the given version is higher.
public setIfHigher({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$version | Version | the version to compare against the current version |
$delimiter | string | optional delimiter used for version comparison |
setIfLower
Sets the current version to the given version if the given version is lower.
public setIfLower({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$version | Version | the version to compare against the current version |
$delimiter | string | optional delimiter to use for version comparison |
Generated by Hazaar API Doc Generator