2017 © Pedro Peláez
 

library version

Semantic versioning helper library

image

rollerworks/version

Semantic versioning helper library

  • Monday, January 1, 2018
  • by sstok
  • Repository
  • 1 Watchers
  • 0 Stars
  • 708 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

Rollerworks Semver Component

A small Semantic Versioning helper library., (*1)

Validation Continues Versions. Finding next possible version version increments., (*2)

Requirements

You need at least PHP 7.1, (*3)

Installation

To install this package, add rollerworks/version to your composer.json, (*4)

$ php composer.phar require rollerworks/version

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*5)

Now, Composer will automatically download all required files, and install them for you., (*6)

Basic usage

require 'vendor/autoload.php';

use Rollerworks\Component\Version\Version;
use Rollerworks\Component\Version\VersionsValidator;

// Creates an immutable Version value-object.
// Any call to this object will produce a new Version object
$version = Version::fromString('v1.3.2');

$newVersion = $version->increase('major');  // v2.0.0
$newVersion = $version->increase('minor');  // v1.4.0
$newVersion = $version->increase('next');   // v1.4.0
$newVersion = $version->increase('patch');  // v1.3.3
$newVersion = $version->increase('stable'); // v1.4.0

$newVersion = $version->increase('alpha'); // v1.4.0-ALPHA1
$newVersion = $version->increase('beta');  // v1.4.0-BETA1
$newVersion = $version->increase('rc');    // v1.4.0-RC1

// ...
// Increasing minor or patch is prohibited until the meta-ver (alpha,beta,rc) is 0
// For patch this resolves to "next".

$version = Version::fromString('v1.4.0-BETA1');
$newVersion = $version->increase('beta');   // v1.4.0-BETA2
$newVersion = $version->increase('rc');     // v1.4.0-RC1
$newVersion = $version->increase('major');  // v1.4.0
$newVersion = $version->increase('next');   // v1.4.0-BETA2
$newVersion = $version->increase('patch');  // v1.4.0-BETA2
$newVersion = $version->increase('stable'); // v1.4.0

// Version validation
// ... //

$existingVersions = [
    Version::fromString('0.1.0'),
    Version::fromString('v1.0.0-beta1'),
    Version::fromString('v1.0.0-beta2'),
    Version::fromString('v1.0.0-beta6'),
    Version::fromString('v1.0.0-beta7'),
    Version::fromString('1.0.0'),
    Version::fromString('v1.0.1'),
    Version::fromString('v1.1.0'),
    Version::fromString('v2.0.0'),
    Version::fromString('v3.5-beta1'),
];

$validator = new ContinuesVersionsValidator(...$existingVersions); // Expects the versions as a variadic arguments
//$validator = new ContinuesVersionsValidator(); // No existing versions

VersionsValidator::isVersionContinues(Version::fromString('v1.1.1'));      // true
VersionsValidator::isVersionContinues(Version::fromString('1.0.2'));       // true
VersionsValidator::isVersionContinues(Version::fromString('1.1.1.'));      // true
VersionsValidator::isVersionContinues(Version::fromString('2.0.1.'));      // true
VersionsValidator::isVersionContinues(Version::fromString('3.5.0-beta2')); // true
VersionsValidator::isVersionContinues(Version::fromString('3.5.0'));       // true

// A new minor or major version is not considered acceptable when there are already higher
// versions. Only patch releases are accepted then.
VersionsValidator::isVersionContinues(Version::fromString('0.2.0'));        // false
VersionsValidator::isVersionContinues(Version::fromString('v1.0.0-beta8')); // false
VersionsValidator::isVersionContinues(Version::fromString('v1.2'));         // false
VersionsValidator::isVersionContinues(Version::fromString('v2.1'));         // false
VersionsValidator::isVersionContinues(Version::fromString('v3.5-alpha1'));  // false
VersionsValidator::isVersionContinues(Version::fromString('v3.5-beta3'));   // false
VersionsValidator::isVersionContinues(Version::fromString('v3.6'));         // false

// A list of possible versions with respect to the major.minor bounds of any existing version
// For higher major.minor versions then validated only suggests a patch release, otherwise
// all possible increments till the next stable major are suggested.
$possibleVersions = $validator->getPossibleVersions();

Versioning

For transparency and insight into the release cycle, and for striving to maintain backward compatibility, this package is maintained under the Semantic Versioning guidelines as much as possible., (*7)

Releases will be numbered with the following format:, (*8)

<major>.<minor>.<patch>, (*9)

And constructed with the following guidelines:, (*10)

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit http://semver.org/., (*11)

License

The source of this package is subject to the MIT license that is bundled with this source code in the file LICENSE., (*12)

This library is maintained by Sebastiaan Stok., (*13)

The Versions

01/01 2018

dev-master

9999999-dev

Semantic versioning helper library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

24/11 2017

v0.2.0

0.2.0.0

Semantic versioning helper library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok

19/03 2017

v0.1.0

0.1.0.0

Semantic versioning helper library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Sebastiaan Stok