diff --git a/src/Helper/SemanticVersion.php b/src/Helper/SemanticVersion.php index aa3f5cd..9ce0284 100644 --- a/src/Helper/SemanticVersion.php +++ b/src/Helper/SemanticVersion.php @@ -11,6 +11,13 @@ class SemanticVersion */ public const PATTERN = '([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?'; + /** + * Pattern no extra. + * + * @var string + */ + public const PATTERN_NO_EXTRA = '([0-9]+)\.([0-9]+)\.([0-9]+)'; + /** * @var string */ @@ -114,6 +121,15 @@ public function getVersion(): string return $this->version; } + public function getVersionCode(): string + { + if (preg_match('/' . self::PATTERN_NO_EXTRA . '/', $this->version, $match)) { + return $match[0]; + } + + return '0.0.0'; + } + public function setVersion(string $version): SemanticVersion { $this->version = $version;