ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Data\Version Class Reference

A version number that consists of three numbers (major, minor, patch). More...

+ Collaboration diagram for ILIAS\Data\Version:

Public Member Functions

 __construct (string $version)
 
 getMajor ()
 
 getMinor ()
 
 getPatch ()
 
 equals (Version $other)
 
 isGreaterThan (Version $other)
 
 isGreaterThanOrEquals (Version $other)
 
 isSmallerThan (Version $other)
 
 isSmallerThanOrEquals (Version $other)
 
 __toString ()
 

Protected Attributes

int $major
 
int $minor
 
int $patch
 

Private Attributes

const REGEXP = '(?<major>\d+)([.](?<minor>\d+)([.](?<patch>\d+))?)?'
 

Detailed Description

A version number that consists of three numbers (major, minor, patch).

Definition at line 26 of file Version.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Data\Version::__construct ( string  $version)

Definition at line 34 of file Version.php.

35 {
36 $match = [];
37 if (!preg_match("/" . self::REGEXP . "/", $version, $match)) {
38 throw new \InvalidArgumentException(
39 "Expected version string '$version' to match this regular expression: " . self::REGEXP
40 );
41 }
42 $this->major = (int) $match["major"];
43 $this->minor = (int) ($match["minor"] ?? 0);
44 $this->patch = (int) ($match["patch"] ?? 0);
45 }
$version
Definition: plugin.php:24

References $version, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ILIAS\Data\Version::__toString ( )

Definition at line 90 of file Version.php.

91 {
92 return "$this->major.$this->minor.$this->patch";
93 }

◆ equals()

ILIAS\Data\Version::equals ( Version  $other)

Definition at line 62 of file Version.php.

62 : bool
63 {
64 return
65 $this->major === $other->major
66 && $this->minor === $other->minor
67 && $this->patch === $other->patch;
68 }

Referenced by ILIAS\Data\Version\isGreaterThanOrEquals(), and ILIAS\Data\Version\isSmallerThanOrEquals().

+ Here is the caller graph for this function:

◆ getMajor()

ILIAS\Data\Version::getMajor ( )

Definition at line 47 of file Version.php.

47 : int
48 {
49 return $this->major;
50 }

References ILIAS\Data\Version\$major.

◆ getMinor()

ILIAS\Data\Version::getMinor ( )

Definition at line 52 of file Version.php.

52 : int
53 {
54 return $this->minor;
55 }

References ILIAS\Data\Version\$minor.

◆ getPatch()

ILIAS\Data\Version::getPatch ( )

Definition at line 57 of file Version.php.

57 : int
58 {
59 return $this->patch;
60 }

References ILIAS\Data\Version\$patch.

◆ isGreaterThan()

ILIAS\Data\Version::isGreaterThan ( Version  $other)

Definition at line 70 of file Version.php.

70 : bool
71 {
72 return version_compare((string) $this, (string) $other, '>');
73 }

Referenced by ILIAS\Data\Version\isGreaterThanOrEquals(), ILIAS\Data\Version\isSmallerThan(), and ILIAS\Data\Version\isSmallerThanOrEquals().

+ Here is the caller graph for this function:

◆ isGreaterThanOrEquals()

ILIAS\Data\Version::isGreaterThanOrEquals ( Version  $other)

Definition at line 75 of file Version.php.

75 : bool
76 {
77 return $this->equals($other) || $this->isGreaterThan($other);
78 }
equals(Version $other)
Definition: Version.php:62
isGreaterThan(Version $other)
Definition: Version.php:70

References ILIAS\Data\Version\equals(), and ILIAS\Data\Version\isGreaterThan().

+ Here is the call graph for this function:

◆ isSmallerThan()

ILIAS\Data\Version::isSmallerThan ( Version  $other)

Definition at line 80 of file Version.php.

80 : bool
81 {
82 return $other->isGreaterThan($this);
83 }

References ILIAS\Data\Version\isGreaterThan().

+ Here is the call graph for this function:

◆ isSmallerThanOrEquals()

ILIAS\Data\Version::isSmallerThanOrEquals ( Version  $other)

Definition at line 85 of file Version.php.

85 : bool
86 {
87 return $other->isGreaterThan($this) || $this->equals($other);
88 }

References ILIAS\Data\Version\equals(), and ILIAS\Data\Version\isGreaterThan().

+ Here is the call graph for this function:

Field Documentation

◆ $major

int ILIAS\Data\Version::$major
protected

Definition at line 30 of file Version.php.

Referenced by ILIAS\Data\Version\getMajor().

◆ $minor

int ILIAS\Data\Version::$minor
protected

Definition at line 31 of file Version.php.

Referenced by ILIAS\Data\Version\getMinor().

◆ $patch

int ILIAS\Data\Version::$patch
protected

Definition at line 32 of file Version.php.

Referenced by ILIAS\Data\Version\getPatch().

◆ REGEXP

const ILIAS\Data\Version::REGEXP = '(?<major>\d+)([.](?<minor>\d+)([.](?<patch>\d+))?)?'
private

Definition at line 28 of file Version.php.


The documentation for this class was generated from the following file: