本文整理汇总了PHP中Version::getPreRelease方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::getPreRelease方法的具体用法?PHP Version::getPreRelease怎么用?PHP Version::getPreRelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Version
的用法示例。
在下文中一共展示了Version::getPreRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: compareTo
/**
* Compares one version with another.
*
* @param Version $left The left version to compare.
* @param Version $right The right version to compare.
*
* @return integer Returns Comparator::EQUAL_TO if the two versions are
* equal. If the left version is less than the right
* version, Comparator::LESS_THAN is returned. If the left
* version is greater than the right version,
* Comparator::GREATER_THAN is returned.
*/
public static function compareTo(Version $left, Version $right)
{
switch (true) {
case $left->getMajor() < $right->getMajor():
return self::LESS_THAN;
case $left->getMajor() > $right->getMajor():
return self::GREATER_THAN;
case $left->getMinor() > $right->getMinor():
return self::GREATER_THAN;
case $left->getMinor() < $right->getMinor():
return self::LESS_THAN;
case $left->getPatch() > $right->getPatch():
return self::GREATER_THAN;
case $left->getPatch() < $right->getPatch():
return self::LESS_THAN;
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
return self::compareIdentifiers($left->getPreRelease(), $right->getPreRelease());
}
示例2: toString
/**
* Returns the string representation of a Version instance.
*
* @param Version $version A version.
*
* @return string The string representation.
*/
public static function toString(Version $version)
{
return sprintf('%d.%d.%d%s%s', $version->getMajor(), $version->getMinor(), $version->getPatch(), $version->getPreRelease() ? '-' . join('.', $version->getPreRelease()) : '', $version->getBuild() ? '+' . join('.', $version->getBuild()) : '');
}