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 = 'none'
__version_parts
private array $__version_parts
Methods
__construct
Version constructor.
public __construct(string $version, ?int $precision, ?string $delimiter): void
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(): void
format
public format(string $version, int $precision, ?string $delimiter): string
Parameters
Parameter | Type | Description |
---|---|---|
$version | string | |
$precision | int | |
$delimiter | string |
set
Sets the version string and updates the version parts and precision.
public set(string $version, ?string $delimiter): void
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(): void
getParts
Get the version parts as an array.
public getParts(): void
compareTo
Compare the version to another version.
public compareTo(Version $that, ?string $delimiter): void
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(Version $that): bool
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(Version $version, ?string $delimiter): void
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(Version $version, ?string $delimiter): void
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