diff --git a/src/SemanticComparator.php b/src/SemanticComparator.php index 02580bd..d9f73d8 100644 --- a/src/SemanticComparator.php +++ b/src/SemanticComparator.php @@ -15,27 +15,20 @@ * @since 1.0.0-rc.1 * @see http://semver.org */ -class SemanticComparator +class SemanticComparator implements SemanticComparatorInterface { /** - * @param SemanticVersion $left - * @param SemanticVersion $right - * @return int - * @see compare() + * @inheritdoc */ - public function __invoke(SemanticVersion $left, SemanticVersion $right) + public function __invoke(SemanticVersionInterface $left, SemanticVersionInterface $right) { return $this->compare($left, $right); } /** - * Build metadata is ignored when determining version precedence. - * - * @param SemanticVersion $left - * @param SemanticVersion $right - * @return int `0` if both versions are equal, `< 0` if `$left` is smaller and `> 0` if `$left` is greater. + * @inheritdoc */ - public function compare(SemanticVersion $left, SemanticVersion $right) + public function compare(SemanticVersionInterface $left, SemanticVersionInterface $right) { $result = $this->compareMajorMinorPatch($left, $right); @@ -47,11 +40,11 @@ public function compare(SemanticVersion $left, SemanticVersion $right) } /** - * @param SemanticVersion $left - * @param SemanticVersion $right + * @param SemanticVersionInterface $left + * @param SemanticVersionInterface $right * @return int */ - private function compareMajorMinorPatch(SemanticVersion $left, SemanticVersion $right) + private function compareMajorMinorPatch(SemanticVersionInterface $left, SemanticVersionInterface $right) { $result = $left->getMajor() - $right->getMajor(); @@ -67,11 +60,11 @@ private function compareMajorMinorPatch(SemanticVersion $left, SemanticVersion $ } /** - * @param SemanticVersion $left - * @param SemanticVersion $right + * @param SemanticVersionInterface $left + * @param SemanticVersionInterface $right * @return int */ - private function comparePre(SemanticVersion $left, SemanticVersion $right) + private function comparePre(SemanticVersionInterface $left, SemanticVersionInterface $right) { if ($left->getPre() === '') { return $right->getPre() === '' ? 0 : 1; diff --git a/src/SemanticComparatorInterface.php b/src/SemanticComparatorInterface.php new file mode 100644 index 0000000..645f18b --- /dev/null +++ b/src/SemanticComparatorInterface.php @@ -0,0 +1,36 @@ + 0` if `$left` is greater. + */ + public function compare(SemanticVersionInterface $left, SemanticVersionInterface $right); +} diff --git a/src/SemanticVersion.php b/src/SemanticVersion.php index ae3aca1..825d13a 100644 --- a/src/SemanticVersion.php +++ b/src/SemanticVersion.php @@ -16,7 +16,7 @@ * @since 1.0.0-rc.1 * @see http://semver.org */ -class SemanticVersion +class SemanticVersion implements SemanticVersionInterface { /** * @var int @@ -81,7 +81,7 @@ public function __construct($version) } /** - * @return string + * @inheritdoc */ public function __toString() { @@ -129,7 +129,7 @@ private function buildException() } /** - * @return int Non-negative integer without leading zeroes. + * @inheritdoc */ public function getMajor() { @@ -137,7 +137,7 @@ public function getMajor() } /** - * @return int Non-negative integer without leading zeroes. + * @inheritdoc */ public function getMinor() { @@ -145,7 +145,7 @@ public function getMinor() } /** - * @return int Non-negative integer without leading zeroes. + * @inheritdoc */ public function getPatch() { @@ -153,7 +153,7 @@ public function getPatch() } /** - * @return string Optional pre-release information. + * @inheritdoc */ public function getPre() { @@ -161,8 +161,7 @@ public function getPre() } /** - * @return string[] - * @since 1.0.0-rc.2 + * @inheritdoc */ public function getPreStack() { @@ -170,7 +169,7 @@ public function getPreStack() } /** - * @return string Optional metadata. + * @inheritdoc */ public function getMeta() { @@ -178,8 +177,7 @@ public function getMeta() } /** - * @return string[] - * @since 1.0.0-rc.2 + * @inheritdoc */ public function getMetaStack() { @@ -187,7 +185,7 @@ public function getMetaStack() } /** - * @return string + * @inheritdoc */ public function getVersion() { diff --git a/src/SemanticVersionInterface.php b/src/SemanticVersionInterface.php new file mode 100644 index 0000000..29258b9 --- /dev/null +++ b/src/SemanticVersionInterface.php @@ -0,0 +1,68 @@ +