Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
72.22% |
13 / 18 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
Version | |
72.22% |
13 / 18 |
|
50.00% |
1 / 2 |
5.54 | |
0.00% |
0 / 1 |
getString | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
getArray | |
61.54% |
8 / 13 |
|
0.00% |
0 / 1 |
2.23 |
1 | <?php |
2 | |
3 | namespace BO\Zmsapi\Helper; |
4 | |
5 | class Version |
6 | { |
7 | public static function getString($path = null) |
8 | { |
9 | $path = ($path) ? $path : \App::APP_PATH; |
10 | $file = $path . '/VERSION'; |
11 | if (is_file($file)) { |
12 | return trim(file_get_contents($file)); |
13 | } |
14 | return "version.unknown"; |
15 | } |
16 | |
17 | public static function getArray($path = null) |
18 | { |
19 | $version = static::getString($path); |
20 | $array = []; |
21 | if (preg_match('#^(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+.*)$#', $version, $array)) { |
22 | return [ |
23 | 'major' => $array['major'], |
24 | 'minor' => $array['minor'], |
25 | 'patch' => $array['patch'], |
26 | ]; |
27 | } |
28 | return [ |
29 | 'major' => "unknown", |
30 | 'minor' => "0", |
31 | 'patch' => "0", |
32 | ]; |
33 | } |
34 | } |