Comparable
This trait adds compare functions to Version.
Table of Contents
Methods
- compare() : int
- Compares two versions.
- compareString() : int
- Compares two version strings.
- equal() : bool
- Compares two version strings and returns true when the first and second are equal.
- greaterThan() : bool
- Compares two version strings and returns true when the first is greater than the second.
- greaterThanOrEqual() : bool
- Compares two version strings and returns true when the first is greater than the second or equal.
- isEqual() : bool
- Compares the version with the given one, returns true when they are equal.
- isGreaterThan() : bool
- Compares the version with the given one, returns true when the current is greater than the other.
- isGreaterThanOrEqual() : bool
- Compares the version with the given one, returns true when the current is greater than the other or equal.
- isLessThan() : bool
- Compares the version with the given one, returns true when the current is less than the other.
- isLessThanOrEqual() : bool
- Compares the version with the given one, returns true when the current is less than the other or equal.
- isNotEqual() : bool
- Compares the version with the given one, returns true when they are not equal.
- lessThan() : bool
- Compares two version strings and returns true when the first is less than the second.
- lessThanOrEqual() : bool
- Compares two version strings and returns true when the first is less than the second or equal.
- notEqual() : bool
- Compares two version strings and returns true when the first and second are not equal.
Methods
compare()
Compares two versions.
public
static compare(Version $v1, Version $v2) : int
Parameters
Return values
int —-1 when $v1 < $v2, 0 when $v1 == $v2, 1 when $v1 > $v2
compareString()
Compares two version strings.
public
static compareString(string $v1, string $v2) : int
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
int —-1 when $v1 < $v2, 0 when $v1 == $v2, 1 when $v1 > $v2
equal()
Compares two version strings and returns true when the first and second are equal.
public
static equal(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 == $v2, otherwise false
greaterThan()
Compares two version strings and returns true when the first is greater than the second.
public
static greaterThan(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 > $v2, otherwise false
greaterThanOrEqual()
Compares two version strings and returns true when the first is greater than the second or equal.
public
static greaterThanOrEqual(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 >= $v2, otherwise false
isEqual()
Compares the version with the given one, returns true when they are equal.
public
isEqual(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance == $v, otherwise false
isGreaterThan()
Compares the version with the given one, returns true when the current is greater than the other.
public
isGreaterThan(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance > $v, otherwise false
isGreaterThanOrEqual()
Compares the version with the given one, returns true when the current is greater than the other or equal.
public
isGreaterThanOrEqual(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance >= $v, otherwise false
isLessThan()
Compares the version with the given one, returns true when the current is less than the other.
public
isLessThan(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance < $v, otherwise false
isLessThanOrEqual()
Compares the version with the given one, returns true when the current is less than the other or equal.
public
isLessThanOrEqual(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance <= $v, otherwise false
isNotEqual()
Compares the version with the given one, returns true when they are not equal.
public
isNotEqual(Version $v) : bool
Parameters
- $v : Version
-
the version to compare
Return values
bool —true when instance != $v, otherwise false
lessThan()
Compares two version strings and returns true when the first is less than the second.
public
static lessThan(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 < $v2, otherwise false
lessThanOrEqual()
Compares two version strings and returns true when the first is less than the second or equal.
public
static lessThanOrEqual(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 <= $v2, otherwise false
notEqual()
Compares two version strings and returns true when the first and second are not equal.
public
static notEqual(string $v1, string $v2) : bool
Parameters
- $v1 : string
-
the left side of the comparison
- $v2 : string
-
the right side of the comparison
Tags
Return values
bool —true when $v1 != $v2, otherwise false