Version
Version
- Full name:
\Hazaar\Version
Properties
default_delimiter
public static string $default_delimiter
- This property is static.
__precision
private ?int $__precision
__version
private string $__version
__version_parts
private string[] $__version_parts
Methods
__construct
Version constructor.
public __construct(string $version, ?int $precision = null, ?string $delimiter = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$version | string | string The version number as a string |
$precision | ?int | |
$delimiter | ?string |
Throws:
__toString
Magic method to output the version as a string.
public __toString(): string
format
Format a version number using the specified precision.
public static format(string[]|string $version, int $precision, string $delimiter = null): string
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$version | string[]|string | the version number to format |
$precision | int | The precision of the version. Normally 2 or 3, where 3 is Major/Minor/Revision. |
$delimiter | string | Optionally override the version delimiter. Normall a single character, ie: a full stop (.). This will be the global default of '.' if not specified. |
set
Sets the version string and updates the version parts and precision.
public set(string $version, null|string $delimiter = null): void
Parameters:
Parameter | Type | Description |
---|---|---|
$version | string | the version string to set |
$delimiter | null|string | The delimiter used in the version string. If null, the default delimiter is used. |
Throws:
if the version string does not match the expected format
get
Get the current version number.
final public get(): string
- This method is final.
getParts
Get the version parts as an array.
public getParts(): string[]
compareTo
Compare the version to another version.
public compareTo(string|\Hazaar\Version $that, ?string $delimiter = null): int
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 | string|\Hazaar\Version | The version to compare against. Can be either a version string or another version object. |
$delimiter | ?string |
Return Value:
either -1, 0 or 1 to indicate if the version is less than, equal to or greater than $that
equals
Compares two versions to see if they are equal.
public equals(string|\Hazaar\Version $that): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$that | string|\Hazaar\Version | The version to compare to |
Return Value:
TRUE or FALSE indicating if the versions are equal
setIfHigher
Sets the current version to the given version if the given version is higher.
public setIfHigher(string|\Hazaar\Version $version, null|string $delimiter = null): void
Parameters:
Parameter | Type | Description |
---|---|---|
$version | string|\Hazaar\Version | the version to compare against the current version |
$delimiter | null|string | optional delimiter used for version comparison |
setIfLower
Sets the current version to the given version if the given version is lower.
public setIfLower(string|\Hazaar\Version $version, null|string $delimiter = null): void
Parameters:
Parameter | Type | Description |
---|---|---|
$version | string|\Hazaar\Version | the version to compare against the current version |
$delimiter | null|string | optional delimiter to use for version comparison |
Automatically generated on 2024-11-14