class Version (View source)

Properties

static protected string $pattern
string $major
string $minor
string $patch
array|null $prerelease
array|null $build

Methods

__construct(string $version)

Parse version format

int
compare(Version $version)

Compare current version with another version

array|int|string|null
__get(string $name)

Get value for a version component

__set(string $name, array|int|string|null $value)

Set value for a version component

string
__toString()

Compose string

static bool
valid(string $version)

Validate string version

Details

__construct(string $version)

Parse version format

Parameters

string $version

int compare(Version $version)

Compare current version with another version

Parameters

Version $version

Return Value

int

returns -1 if the current version is lower than the second, 0 if they are equal, and 1 if the second is lower.

array|int|string|null __get(string $name)

Get value for a version component

Parameters

string $name

Return Value

array|int|string|null

__set(string $name, array|int|string|null $value)

Set value for a version component

Parameters

string $name
array|int|string|null $value

Exceptions

Exception

string __toString()

Compose string

Return Value

string

static bool valid(string $version)

Validate string version

Parameters

string $version

Return Value

bool