fractal / semver
The package helps to work with semantic versions.
v1.0.1
2019-09-25 11:23 UTC
Requires
- php: ^7.1
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.23.4
- php-coveralls/php-coveralls: ^2.1
- phpunit/php-code-coverage: ^6.1
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2024-10-25 22:48:21 UTC
README
Coverage and Quality:
Build:
Other:
Features
- Simple package for semantic version manipulation.
- Compare semantic version.
- Validates semantic version.
- Throws exceptions if Versions are not instance of each other.
Usage
Fractal\SemVer\SemanticVersion class:
<?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
Fractal\SemVer\Comparator class:
<?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
License
The SemVer package is open-sourced software licensed under the MIT license.