Merge pull request #4017 from dokuwiki-translate/lang_update_685_1690411879
[dokuwiki.git] / inc / Info.php
blob9208b2471d85271d78c75bcdcd4a68ac2e4a27d9
1 <?php
3 namespace dokuwiki;
5 /**
6 * Basic Information about DokuWiki
8 * @todo much of infoutils should be moved here
9 */
10 class Info
13 /**
14 * Parse the given version string into its parts
16 * @param string $version
17 * @return array
18 * @throws \Exception
20 static public function parseVersionString($version)
22 $return = [
23 'type' => '', // stable, rc
24 'date' => '', // YYYY-MM-DD
25 'hotfix' => '', // a, b, c, ...
26 'version' => '', // sortable, full version string
27 'codename' => '', // codename
28 'raw' => $version, // raw version string as given
31 if (preg_match('/^(rc)?(\d{4}-\d{2}-\d{2})([a-z]*)/', $version, $matches)) {
32 $return['date'] = $matches[2];
33 if ($matches[1] == 'rc') {
34 $return['type'] = 'rc';
35 } else {
36 $return['type'] = 'stable';
38 if ($matches[3]) {
39 $return['hotfix'] = $matches[3];
41 } else {
42 throw new \Exception('failed to parse version string');
45 [, $return['codename']] = sexplode(' ', $version, 2);
46 $return['codename'] = trim($return['codename'], ' "');
48 $return['version'] = $return['date'];
49 $return['version'] .= $return['type'] == 'rc' ? 'rc' : $return['hotfix'];
51 return $return;