/**
  * is $a > $b?
  *
  * @param  VersionNumber|string $a
  *         the LHS of this calculation
  * @param  VersionNumber|string $b
  *         the RHS of this calculation
  * @param  VersionParser|null $parser
  *         the parser to use if $a or $b are strings
  * @return boolean
  *         TRUE if $a > $b
  *         FALSE otherwise
  */
 public static function calculate($a, $b, VersionParser $parser = null)
 {
     $aObj = EnsureVersionNumber::from($a, $parser);
     $bObj = EnsureCompatibleVersionNumber::from($aObj, $b, $parser);
     return CompareTwoVersionNumbers::calculate($aObj, $bObj, self::$resultsMap);
 }
 /**
  * is $a compatible with $b, according to the rules of the
  * ^ operator?
  *
  * @param  VersionNumber|string $a
  *         the LHS of this calculation
  * @param  VersionNumber|string $b
  *         the RHS of this calculation
  * @param  VersionParser|null $parser
  *         the parser to use if $a or $b are strings
  * @return boolean
  *         TRUE if $a is compatible with $b
  *         FALSE otherwise
  */
 public static function calculate($a, $b, VersionParser $parser = null)
 {
     // make sure $b is something we can work with
     $aObj = EnsureVersionNumber::from($a, $parser);
     $bObj = EnsureCompatibleVersionNumber::from($aObj, $b, $parser);
     // calculate the upper boundary
     $c = $bObj->getCompatibleUpperBoundary();
     // is $a compatible with $b?
     return InBetween::calculate($aObj, $bObj, $c);
 }
 /**
  * is $a approximately equal to $b, according to the rules of the
  * ~ operator?
  *
  * NOTES:
  *
  * - you can only use the ~ operator to pin down which major / minor
  *   version to limit to, not the preRelease level
  *
  * @param  VersionNumber|string $a
  *         the LHS of this calculation
  * @param  VersionNumber|string $b
  *         the RHS of this calcuation
  * @param  VersionParser|null $parser
  *         the parser to use if $a or $b are strings
  * @return boolean
  *         TRUE if $a ~= $b
  *         FALSE otherwise
  */
 public static function calculate($a, $b, VersionParser $parser = null)
 {
     $aObj = EnsureVersionNumber::from($a, $parser);
     $bObj = EnsureCompatibleVersionNumber::from($aObj, $b);
     $c = $bObj->getApproximateUpperBoundary();
     return InBetween::calculate($aObj, $bObj, $c);
 }
 /**
  * @covers ::from
  * @expectedException GanbaroDigital\Versions\Exceptions\E4xx_IncompatibleVersionNumbers
  * @expectedExceptionMessage RHS (of type 'GanbaroDigital\Versions\SemanticVersions\Values\SemanticVersion') is not compatible with LHS (of type 'GanbaroDigital\Versions\VersionNumbers\Internal\Coercers\FakeVersionNumber')
  */
 public function testThrowsExceptionWhenTypesAreNotCompatible()
 {
     // ----------------------------------------------------------------
     // setup your test
     $version = new FakeVersionNumber();
     $parser = new ParseSemanticVersion();
     // ----------------------------------------------------------------
     // perform the change
     EnsureCompatibleVersionNumber::from($version, '1.0.0', $parser);
 }
 /**
  * is $a the same version as $b, discounting the pre-release string?
  *
  * @param  VersionNumber|string $a
  *         the LHS of this calculation
  * @param  VersionNumber|string $b
  *         the RHS of this calculation
  * @param  VersionParser|null $parser
  *         the parser to use if $a or $b are strings
  * @return boolean
  *         TRUE if $a == $b (discounting pre-release string)
  *         FALSE otherwise
  */
 public static function calculate($a, $b, VersionParser $parser = null)
 {
     // make sure we have something we can use
     $aObj = EnsureVersionNumber::from($a, $parser);
     $bObj = EnsureCompatibleVersionNumber::from($aObj, $b, $parser);
     if ($aObj->getMajor() != $bObj->getMajor()) {
         return false;
     }
     if ($aObj->getMinor() != $bObj->getMinor()) {
         return false;
     }
     if ($aObj->getPatchLevel() != $bObj->getPatchLevel()) {
         return false;
     }
     return true;
 }
 /**
  * is $a a pre-release of $b?
  *
  * @param  VersionNumber|string $a
  *         the LHS of this calculation
  * @param  VersionNumber|string $b
  *         the RHS of this calculation
  * @param  VersionParser|null $parser
  *         the parser to use if $a or $b are strings
  * @return boolean
  *         TRUE if $a < $b
  *         FALSE otherwise
  */
 public static function calculate($a, $b, VersionParser $parser = null)
 {
     $aObj = EnsureVersionNumber::from($a, $parser);
     $bObj = EnsureCompatibleVersionNumber::from($aObj, $b, $parser);
     // quickest test of all ... is $a a pre-release?
     if (!$aObj->hasPreRelease()) {
         return false;
     }
     return SameVersion::calculate($aObj, $bObj);
 }