/** * 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); }
/** * @covers ::calculate * @dataProvider provideNonStrings * @expectedException GanbaroDigital\TextTools\Exceptions\E4xx_UnsupportedType */ public function testRejectsNonStrings($lhs, $rhs) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change CompareTwoStrings::calculate($lhs, $rhs); }