OpenAPI Generator. Better DocBlock parsing [WIP]
[dokuwiki.git] / inc / Info.php
blob1cdccd7a063bcc78eb6a8f2f876c538e349a0c14
1 <?php
3 namespace dokuwiki;
5 /**
6 * Basic Information about DokuWiki
8 * @todo much of infoutils should be moved here
9 */
10 class Info
12 /**
13 * Parse the given version string into its parts
15 * @param string $version
16 * @return array
17 * @throws \Exception
19 public static function parseVersionString($version)
21 $return = [
22 'type' => '', // stable, rc
23 'date' => '', // YYYY-MM-DD
24 'hotfix' => '', // a, b, c, ...
25 'version' => '', // sortable, full version string
26 'codename' => '', // codename
27 'raw' => $version, // raw version string as given
30 if (preg_match('/^(rc)?(\d{4}-\d{2}-\d{2})([a-z]*)/', $version, $matches)) {
31 $return['date'] = $matches[2];
32 if ($matches[1] == 'rc') {
33 $return['type'] = 'rc';
34 } else {
35 $return['type'] = 'stable';
37 if ($matches[3]) {
38 $return['hotfix'] = $matches[3];
40 } else {
41 throw new \Exception('failed to parse version string');
44 [, $return['codename']] = sexplode(' ', $version, 2);
45 $return['codename'] = trim($return['codename'], ' "');
47 $return['version'] = $return['date'];
48 $return['version'] .= $return['type'] == 'rc' ? 'rc' : $return['hotfix'];
50 return $return;