/** * This method tests the "compare" method. */ public function test_compare() { $x = IBool\Type::true(); $y = IBool\Type::false(); $z = IBool\Module::compare($x, $y); $this->assertInstanceOf('\\Saber\\Data\\ITrit\\Type', $z); $this->assertSame(1, $z->unbox()); $z = IBool\Module::compare($x, $x); $this->assertInstanceOf('\\Saber\\Data\\ITrit\\Type', $z); $this->assertSame(0, $z->unbox()); $z = IBool\Module::compare($y, $x); $this->assertInstanceOf('\\Saber\\Data\\ITrit\\Type', $z); $this->assertSame(-1, $z->unbox()); }
/** * This method returns the numerically lowest value. * * @access public * @static * @param IBool\Type $x the left operand * @param IBool\Type $y the right operand * @return IBool\Type the minimum value */ public static function min(IBool\Type $x, IBool\Type $y) : IBool\Type { return IBool\Module::compare($x, $y)->unbox() <= 0 ? $x : $y; }