- Simple package for semantic version manipulation.
- Compare semantic version.
- Validates semantic version.
- Throws exceptions if Versions are not instance of each other.
<?php
use Fractal\SemVer\SemanticVersion;
## Create instance of SemVer
## If SemVer not valid, throws \Fractal\SemVer\Exceptions\ParseVersionException
$version = SemanticVersion::fromString('1.0.0'); # \Fractal\SemVer\Contracts\VersionInterface
$other = SemanticVersion::fromString('0.1.0'); # \Fractal\SemVer\Contracts\VersionInterface
## Version can compare each other
## If compare operator not valid, throws \Fractal\SemVer\Exceptions\InvalidOperatorException
## If version and other version are not instance of each other, throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException
$version->eq($other); # false
$version->gte($other); # true
<?php
use Fractal\SemVer\SemanticVersion;
use Fractal\SemVer\Comparator;
## Create instance of SemVer
## If SemVer not valid, throws \Fractal\SemVer\Exceptions\ParseVersionException
$version = SemanticVersion::fromString('1.0.0'); # \Fractal\SemVer\Contracts\VersionInterface
$other = SemanticVersion::fromString('0.1.0'); # \Fractal\SemVer\Contracts\VersionInterface
## Compare versions with comparator
## If compare operator not valid, throws \Fractal\SemVer\Exceptions\InvalidOperatorException
## If version and other version are not instance of each other, throws \Fractal\SemVer\Exceptions\VersionClassNotEqualException
Comparator::eq($version, $other); # false
Comparator::gte($version, $other); # true
The SemVer package is open-sourced software licensed under the MIT license.