/** * make sure that $a and $b are types that can be used together in * any of our operators * * $b will be transformed (if necessary) to a type that is compatible * with $a * * @param VersionNumber $a * a version number * @param VersionNumber|string $b * a second version number * @param VersionParser|null $parser * the parser to use if $b is a string * @return VersionNumber * a version number with the value of $b, compatible with $a */ public static function from(VersionNumber $a, $b, VersionParser $parser = null) { // convert $b to a string if needed $bObj = EnsureVersionNumber::from($b, $parser); // do we have a match? if (VersionNumbersAreCompatible::check($a, $bObj)) { return $bObj; } // if we get here, then no we do not throw new E4xx_IncompatibleVersionNumbers($a, $bObj); }
/** * @covers ::check * @covers ::getCompatibleVersionSubclasses * @dataProvider provideVersionNumbers */ public function testCanCallStatically($lhs, $rhs, $expectedResult) { // ---------------------------------------------------------------- // setup your test $parser = new ParseSemanticVersion(); // ---------------------------------------------------------------- // perform the change $actualResult = VersionNumbersAreCompatible::check($lhs, $rhs); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }