/** * This method tests the "covariant" method. */ public function test_covariant() { $p0 = IEither\Type::covariant(IEither\Type::left(IInt32\Type::zero())); $this->assertInstanceOf('\\Saber\\Data\\IEither\\Left\\Type', $p0); $p1 = IEither\Type::covariant(IEither\Type::right(IInt32\Type::zero())); $this->assertInstanceOf('\\Saber\\Data\\IEither\\Right\\Type', $p1); }
/** * This method binds the specified subroutine to the projection's object. * * @access public * @final * @param callable $subroutine the subroutine to bind * @return IEither\Type the either */ public final function bind(callable $subroutine) : IEither\Type { return $this->either->__isLeft() ? IEither\Type::covariant($subroutine($this->either->item(), IInt32\Type::zero())) : IEither\Type::right($this->either->projectLeft()->item()); }