ceus-media / semantic-versioning
Semantic Versioning
0.2.0
2024-02-25 04:07 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpstan/phpstan: *
- phpstan/phpstan-strict-rules: *
- phpunit/phpunit: *
- vimeo/psalm: ^4.0@dev
This package is auto-updated.
Last update: 2024-12-25 06:11:46 UTC
README
Simple (and by now incomplete) implementation of Semantic Versioning for PHP 8.
Installation
composer require ceus-media/semantic-versioning
Usage
Create a version and manipulate:
$v = new Version( '1.2.3' ); $v->incrementPatch(); // --> 1.2.4 $v->incrementMinor(); // --> 1.3.0 $v->incrementMajor(); // --> 2.0.0
Compare versions:
$v1 = new Version( '1.2.3' ); $v2 = new Version( '1.2.4' ); $v2->isLowerThan( $v1 ); // --> no $v2->isGreaterThan( $v1 ); // --> yes $v2->isAtLeast( $v1 ); // --> yes $v2->isAtMost( $v1 ); // --> no $v2->isEqualTo( $v1 ); // --> no $v2->isDifferentFrom( $v1 ); // --> yes
Define ranges and compare :
$r = new Range( '^1.2' ); Renderer::render( $r ); // -> '^1.2.0 $r->checkVersion( '1.0.0' ) // --> n; $r->checkVersion( '1.1.0' ) // --> n; $r->checkVersion( '1.2.0' ) // --> y; $r->checkVersion( '1.3.0' ) // --> n; $r->checkVersion( '2.0.0' ) // --> n;
Constraints:
... to be documented