/**
  * @covers ::calculate
  * @dataProvider provideNumbers
  */
 public function testCanCheckForIsApproximate($a, $b, $expectedResult)
 {
     // ----------------------------------------------------------------
     // setup your test
     // ----------------------------------------------------------------
     // perform the change
     $actualResult = CompareTwoNumbers::calculate($a, $b);
     // ----------------------------------------------------------------
     // test the results
     $this->assertEquals($expectedResult, $actualResult);
 }
 /**
  * compare a single part of a pre-release string
  *
  * each one of these can be:
  *
  * - a number (a string that's a number)
  * - a string (a string that isn't a number)
  *
  * @param  string $aPart
  * @param  string $bPart
  * @return int
  */
 public static function calculate($aPart, $bPart)
 {
     // what are we looking at?
     $aPartIsNumeric = ctype_digit($aPart);
     $bPartIsNumeric = ctype_digit($bPart);
     if (!$aPartIsNumeric && !$bPartIsNumeric) {
         // two strings to compare
         return CompareTwoStrings::calculate($aPart, $bPart);
     }
     if (($retval = self::calculatePartDifference($aPartIsNumeric, $bPartIsNumeric)) !== CompareTwoNumbers::BOTH_ARE_EQUAL) {
         return $retval;
     }
     // at this point, we have two numbers
     return CompareTwoNumbers::calculate($aPart, $bPart);
 }
 /**
  * compare the X.Y.Z parts of two version numbers
  *
  * @param  array $a
  * @param  array $b
  * @return int
  *         -1 if $aVer is smaller
  *          0 if both are equal
  *          1 if $aVer is larger
  */
 private static function compareXyz($a, $b)
 {
     // compare each part in turn
     foreach (['major', 'minor', 'patchLevel'] as $key) {
         $aN = self::getVersionPart($a, $key, 0);
         $bN = self::getVersionPart($b, $key, 0);
         // compare the two parts
         $res = CompareTwoNumbers::calculate($aN, $bN);
         // are they different?
         if ($res !== CompareTwoNumbers::BOTH_ARE_EQUAL) {
             return $res;
         }
     }
     // if we get here, then both $a and $b have the same X.Y.Z
     return CompareTwoNumbers::BOTH_ARE_EQUAL;
 }