-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VersionInterface.php
62 lines (51 loc) · 1.13 KB
/
VersionInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
declare(strict_types=1);
namespace SonsOfPHP\Component\Version;
use SonsOfPHP\Component\Version\Exception\VersionException;
/**
* Version Interface.
*
* @author Joshua Estes <joshua@sonsofphp.com>
*/
interface VersionInterface
{
/**
* $version = Version::from('1.2.3');.
*
* @throws VersionException
*
* @return static
*/
public static function from(string $version): self;
/**
* Returns the version.
*/
public function toString(): string;
/**
* Returns the Major Version.
*/
public function getMajor(): int;
/**
* Returns the Minor Version.
*/
public function getMinor(): int;
/**
* Returns the Patch Version.
*/
public function getPatch(): int;
/**
* Returns the Pre-release (if any).
*/
public function getPreRelease(): ?string;
/**
* Returns the Build Metadata (if any).
*/
public function getBuild(): ?string;
/**
* Returns
* -1 = $this < $version
* 0 = $this === $version
* 1 = $this > $version.
*/
public function compare(self $version): int;
}