/** * This method enforces that the specified class is a covariant. * * @access public * @static * @param IUnit\Type $x the class to be evaluated * @return IUnit\Type the class */ public static function covariant(IUnit\Type $x = null) : IUnit\Type { if ($x === null) { return IUnit\Type::instance(); } return $x; }
/** * This method iterates over the items in the either, yielding each item to the * procedure function. * * @access public * @final * @param callable $procedure the procedure function to be used * @return IEither\Projection the projection */ public final function each(callable $procedure) : IEither\Projection { if ($this->either->__isLeft()) { IUnit\Type::covariant($procedure($this->either->item(), IInt32\Type::zero())); } return $this; }
/** * This method tests the "toString" method. */ public function test_toString() { $p0 = IUnit\Type::instance()->toString(); $e0 = 'null'; $this->assertInstanceOf('\\Saber\\Data\\IString\\Type', $p0); $this->assertSame($e0, $p0->unbox()); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IUnit\Type $x the left operand * @param Core\Type $y the right operand * @return IBool\Type whether the left operand is identical * to the right operand */ public static function id(IUnit\Type $x, Core\Type $y) : IBool\Type { // === $type = $x === null ? '\\Saber\\Data\\IUnit\\Type' : $x->__typeOf(); return IBool\Type::box($y === null || $type === $y->__typeOf()); }
/** * This method iterates over the items in the option, yielding each item to the * procedure function. * * @access public * @static * @param IOption\Type $xs the left operand * @param callable $procedure the procedure function to be used * @return IOption\Type the option */ public static function each(IOption\Type $xs, callable $procedure) : IOption\Type { if ($xs->__isDefined()) { IUnit\Type::covariant($procedure($xs->item(), IInt32\Type::zero())); } return $xs; }
/** * This method sets the procedure that will be executed should "y" equal "x". * * @access public * @final * @param Core\Equality\Type $y the object to be evaluated * against * @param callable $procedure the procedure to be executed * @return Control\Choice\Type a reference to the next choice * monad node */ public final function when(Core\Equality\Type $y, callable $procedure) : Control\Choice\Type { $this->predicate = function ($x) use($y, $procedure) { if ($y->__eq($x)) { IUnit\Type::covariant($procedure($x)); return true; } return false; }; return Control\Choice\Type::cons($this->x, $this); }
/** * This method returns an item after removing it from the collection. * * @access public * @final * @param Core\Type $key the key associated with the * item to be removed * @return Core\Type the item removed */ public final function removeKey(Core\Type $key) : Core\Type { $hashCode = $key->__hashCode(); $item = IUnit\Type::instance(); if (array_key_exists($hashCode, $this->value)) { $bucket = $this->value[$hashCode]; $buffer = array(); foreach ($bucket as $entry) { if ($entry->first()->__ne($key)) { $buffer[] = $entry; } else { $item = $entry->second(); } } if (empty($buffer)) { unset($this->value[$hashCode]); } else { $this->value[$hashCode] = $buffer; } } return $item; }
/** * This method iterates over the items in the string, yielding each item to the procedure * function. * * @access public * @static * @param IString\Type $xs the left operand * @param callable $procedure the procedure function to be used * @return IString\Type the string */ public static function each(IString\Type $xs, callable $procedure) : IString\Type { $xi = IString\Module::iterator($xs); foreach ($xi as $i => $x) { IUnit\Type::covariant($procedure($x, $i)); } return $xs; }
/** * This method tests the "min" method. */ public function test_min() { $p0 = IUnit\Module::min(IUnit\Type::instance(), IUnit\Type::instance()); $this->assertInstanceOf('\\Saber\\Data\\IUnit\\Type', $p0); $this->assertNull($p0->unbox()); }
/** * This method provides the data for testing that an item exists in the collection. * * @return array */ public function dataItem() { $data = array(array(array(IString\Type::box('key0')), array(IInt32\Type::zero())), array(array(IString\Type::box('key1')), array(IInt32\Type::one())), array(array(IString\Type::box('key2')), array(IInt32\Type::box(2))), array(array(IString\Type::box('key3')), array(IUnit\Type::instance()))); return $data; }
/** * This method returns a right node containing the specified value. * * @access public * @static * @param Core\Type $x the object to be boxed * @return IEither\Right\Type a right node */ public static function right(Core\Type $x = null) : IEither\Right\Type { if ($x === null) { $x = IUnit\Type::instance(); } return new IEither\Right\Type($x); }