rayne/semantic-versioning 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rayne/semantic-versioning

最新稳定版本:1.1.0

Composer 安装命令:

composer require rayne/semantic-versioning

包简介

A tiny independent library for parsing and comparing semantic versions.

README 文档

README

A tiny independent library for parsing and comparing semantic versions which is compatible with Semantic Versioning 2.0.

Latest Stable Version Latest Unstable Version Build Status Code Coverage Scrutinizer Code Quality License

Dependencies

Production

  • PHP 5.6 or better

Development

  • Composer
  • Git
  • PHPUnit

Setup

Download Composer and install rayne/semantic-versioning.

composer require rayne/semantic-versioning

Tests

  1. Clone the repository

    git clone https://github.com/rayne/semantic-versioning.php.git
    
  2. Install the development dependencies

    composer install --dev
    
  3. Run the tests

    ./vendor/bin/phpunit
    

Examples

The library contains the following classes:

  • InvalidVersionException: Thrown by SemanticVersion on invalid input

  • SemanticComparator: The semantic versioning comparator for comparing SemanticVersion objects

  • SemanticVersion: The semantic versioning parser which throws a RuntimeException on invalid versions

The examples are part of the test suite. Have a look at the tests directory for more information.

Interpret semantic versions

use Rayne\SemanticVersioning\SemanticVersion;

$version = new SemanticVersion('1.0.0-beta+exp.sha.5114f85');

assert('1.0.0-beta+exp.sha.5114f85' === (string) $version);
assert( 1                           === $version->getMajor());
assert(   0                         === $version->getMinor());
assert(     0                       === $version->getPatch());
assert(      'beta'                 === $version->getPre());
assert(           'exp.sha.5114f85' === $version->getMeta());
assert('1.0.0-beta+exp.sha.5114f85' === $version->getVersion());

assert(true  === $version->isMajorRelease());
assert(false === $version->isMinorRelease());
assert(false === $version->isPatchRelease());
assert(true  === $version->isPreRelease());

Compare semantic versions

use Rayne\SemanticVersioning\SemanticComparator;
use Rayne\SemanticVersioning\SemanticVersion;

$comparator     = new SemanticComparator;

$alpha          = new SemanticVersion('1.0.0-alpha');
$candidate      = new SemanticVersion('1.0.0-rc.1');
$candidate_meta = new SemanticVersion('1.0.0-rc.1+ci');
$release        = new SemanticVersion('1.0.0');

// $alpha < $candidate
assert($comparator($alpha, $candidate) < 0);
assert($comparator->compare($alpha, $candidate) < 0);

// $candidate == $candidate_meta
assert($comparator($candidate, $candidate_meta) == 0);
assert($comparator->compare($candidate, $candidate_meta) == 0);

// $release > $candidate
assert($comparator($release, $candidate) > 0);
assert($comparator->compare($release, $candidate) > 0);

Sort semantic versions

use Rayne\SemanticVersioning\SemanticComparator;
use Rayne\SemanticVersioning\SemanticVersion;

$versions = [
	$candidate = new SemanticVersion('1.0.0-rc.1'),
	$release   = new SemanticVersion('1.0.0'),
	$alpha     = new SemanticVersion('1.0.0-alpha'),
];

// Sort by semantic precedence.
usort($versions, new SemanticComparator);

assert($versions[0] === $alpha);
assert($versions[1] === $candidate);
assert($versions[2] === $release);

统计信息

  • 总下载量: 211
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固