A DataModel
representing the components of a SemVer string.
Install the package via Composer:
composer require zero-to-prod/data-model-semver
Pass a SemVer string to the from()
method.
$Semver = \Zerotoprod\DataModelSemver\Semver::from('1.2.3-prerelease+meta');
echo $Semver->major; // 1
echo $Semver->minor; // 2
echo $Semver->patch; // 3
echo $Semver->prerelease; // prerelease
echo $Semver->buildmetadata; //meta
Semver::from('1.2.3-prerelease+meta')->toArray();
Semver::from('1.2.3-prerelease+meta')->toJson();