/usr/share/php/PharIo/Version/VersionConstraintValue.php is in php-phar-io-version 1.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | <?php
namespace PharIo\Version;
class VersionConstraintValue
{
/**
* @var VersionNumber
*/
private $major;
/**
* @var VersionNumber
*/
private $minor;
/**
* @var VersionNumber
*/
private $patch;
/**
* @var string
*/
private $label = '';
/**
* @var string
*/
private $buildMetaData = '';
/**
* @var string
*/
private $versionString = '';
/**
* @param string $versionString
*/
public function __construct($versionString) {
$this->versionString = $versionString;
$this->parseVersion($versionString);
}
/**
* @param $versionString
*/
private function parseVersion($versionString) {
$this->extractBuildMetaData($versionString);
$this->extractLabel($versionString);
$versionSegments = explode('.', $versionString);
$this->major = new VersionNumber($versionSegments[0]);
$minorValue = isset($versionSegments[1]) ? $versionSegments[1] : null;
$patchValue = isset($versionSegments[2]) ? $versionSegments[2] : null;
$this->minor = new VersionNumber($minorValue);
$this->patch = new VersionNumber($patchValue);
}
/**
* @param string $versionString
*/
private function extractBuildMetaData(&$versionString) {
if (preg_match('/\+(.*)/', $versionString, $matches) == 1) {
$this->buildMetaData = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
/**
* @param string $versionString
*/
private function extractLabel(&$versionString) {
if (preg_match('/\-(.*)/', $versionString, $matches) == 1) {
$this->label = $matches[1];
$versionString = str_replace($matches[0], '', $versionString);
}
}
/**
* @return string
*/
public function getLabel() {
return $this->label;
}
/**
* @return string
*/
public function getBuildMetaData() {
return $this->buildMetaData;
}
/**
* @return string
*/
public function getVersionString() {
return $this->versionString;
}
/**
* @return VersionNumber
*/
public function getMajor() {
return $this->major;
}
/**
* @return VersionNumber
*/
public function getMinor() {
return $this->minor;
}
/**
* @return VersionNumber
*/
public function getPatch() {
return $this->patch;
}
}
|