|
1
|
|
|
<?php |
|
2
|
|
|
namespace phpbu\App; |
|
3
|
|
|
|
|
4
|
|
|
use SebastianBergmann; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Application Version. |
|
8
|
|
|
* |
|
9
|
|
|
* @package phpbu |
|
10
|
|
|
* @subpackage App |
|
11
|
|
|
* @author Sebastian Feldmann <[email protected]> |
|
12
|
|
|
* @copyright Sebastian Feldmann <[email protected]> |
|
13
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
14
|
|
|
* @link http://phpbu.de/ |
|
15
|
|
|
* @since Class available since Release 1.0.0 |
|
16
|
|
|
* @internal |
|
17
|
|
|
*/ |
|
18
|
|
|
final class Version |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Current version |
|
22
|
|
|
* |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
private static $version; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Path to application root directory. |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
private $path; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Current release version. |
|
36
|
|
|
* |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $release; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Current version number. |
|
43
|
|
|
* |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
private $number; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @param string $release |
|
50
|
|
|
* @param string $path |
|
51
|
|
|
*/ |
|
52
|
3 |
|
public function __construct($release, $path) |
|
53
|
|
|
{ |
|
54
|
3 |
|
$this->release = $release; |
|
55
|
3 |
|
$this->path = $path; |
|
56
|
3 |
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Return the full version number. |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
3 |
|
public function getVersionNumber() : string |
|
64
|
|
|
{ |
|
65
|
3 |
|
if ($this->number === null) { |
|
66
|
3 |
|
if (count(explode('.', $this->release)) == 3) { |
|
67
|
1 |
|
$this->number = $this->release; |
|
68
|
|
|
} else { |
|
69
|
2 |
|
$this->number = $this->release . '-dev'; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
3 |
|
return $this->number; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Return the current version of PHPUnit. |
|
77
|
|
|
* |
|
78
|
|
|
* @return string |
|
79
|
|
|
*/ |
|
80
|
2 |
|
public static function id() : string |
|
81
|
|
|
{ |
|
82
|
2 |
|
if (self::$version === null) { |
|
83
|
1 |
|
$version = new self('5.1', dirname(dirname(__DIR__))); |
|
84
|
1 |
|
self::$version = $version->getVersionNumber(); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
2 |
|
return self::$version; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* Return the minor version number e.g. x.x, x.y, x.z |
|
92
|
|
|
* |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
public static function minor() : string |
|
96
|
|
|
{ |
|
97
|
|
|
if (\strpos(self::id(), '-')) { |
|
98
|
|
|
$version = \explode('-', self::id())[0]; |
|
99
|
|
|
} else { |
|
100
|
|
|
$version = self::id(); |
|
101
|
|
|
} |
|
102
|
|
|
return \implode('.', \array_slice(\explode('.', $version), 0, 2)); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Return the version string. |
|
107
|
|
|
* |
|
108
|
|
|
* @return string |
|
109
|
|
|
*/ |
|
110
|
1 |
|
public static function getVersionString() : string |
|
111
|
|
|
{ |
|
112
|
1 |
|
return 'phpbu ' . self::id() . ' by Sebastian Feldmann and contributors.'; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|