/** * This method returns the latter value should the former value evaluates * to null. * * @access public * @static * @param IOption\Type $xs the value to be evaluated * @param IOption\Type $ys the default value * @return IOption\Type the result */ public static function nvl(IOption\Type $xs = null, IOption\Type $ys = null) : IOption\Type { return $xs ?? $ys ?? IOption\Type::none(); }
/** * This method tests the "size" method. */ public function test_size() { $p0 = IOption\Type::some(IInt32\Type::zero())->size(); $e0 = 1; $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p0); $this->assertSame($e0, $p0->unbox()); $p1 = IOption\Type::none()->size(); $e1 = 0; $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $p1); $this->assertSame($e1, $p1->unbox()); }
/** * This method returns an option using the tail for the boxed object. * * @access public * @static * @param IString\Type $xs the left operand * @return IOption\Type the option */ public static function tailOption(IString\Type $xs) : IOption\Type { return $xs->__isEmpty() ? IOption\Type::none() : IOption\Type::some($xs->tail()); }
/** * This method returns the either as an option. * * @access public * @final * @return IOption\Type the either as an option */ public final function toOption() : IOption\Type { return $this->either->__isLeft() ? IOption\Type::some($this->either->item()) : IOption\Type::none(); }