/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IObject\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(IObject\Type $x, Core\Type $y) : IBool\Type { // === if ($y !== null) { if ($x->__typeOf() === $y->__typeOf()) { return IBool\Type::box($x->unbox() === $y->unbox()); } } return IBool\Type::false(); }
/** * This method evaluates whether the specified object is identical to the current object. * * @access public * @static * @param IOption\Type $xs the left operand * @param Core\Type $ys the object to be evaluated * @return IBool\Type whether the specified object is identical * to the current object */ public static function id(IOption\Type $xs, Core\Type $ys) : IBool\Type { if ($ys !== null) { if ($xs->__typeOf() === $ys->__typeOf()) { if ($ys instanceof IOption\Some\Type) { $x = $xs->item(); $y = $ys->item(); if ($x === null) { return IBool\Type::box($y === null); } else { if ($x instanceof Core\Equality\Type) { return $x->id($y); } } return IBool\Type::box(spl_object_hash($x) === spl_object_hash($y)); } else { if ($ys instanceof IOption\None\Type) { return IBool\Type::true(); } } } } return IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param Throwable\Runtime\Exception $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(Throwable\Runtime\Exception $x, Core\Type $y) { // === if ($y !== null) { if ($x->__typeOf() === $y->__typeOf()) { return IBool\Type::box($x->__hashCode() === $y->__hashCode()); } } return IBool\Type::false(); }
/** * This method tests the "xor_" method. */ public function test_xor_() { $x = IBool\Type::true(); $y = IBool\Type::false(); $z = IBool\Module::xor_($x, $y); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z); $this->assertSame(true, $z->unbox()); $z = IBool\Module::xor_($x, $x); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z); $this->assertSame(false, $z->unbox()); $z = IBool\Module::xor_($y, $x); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z); $this->assertSame(true, $z->unbox()); $z = IBool\Module::xor_($y, $y); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z); $this->assertSame(false, $z->unbox()); }
/** * This method evaluates whether the specified object is identical to the current object. * * @access public * @static * @param IString\Type $xs the left operand * @param Core\Type $ys the object to be evaluated * @return IBool\Type whether the specified object is identical * to the current object */ public static function id(IString\Type $xs, Core\Type $ys) : IBool\Type { if ($ys !== null) { if ($xs->__typeOf() === $ys->__typeOf()) { return IBool\Type::box($xs->unbox() === $ys->unbox()); } } return IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IInt32\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(IInt32\Type $x, Core\Type $y) : IBool\Type { // === if ($x->__typeOf() === $y->__typeOf()) { return IBool\Type::box($x->unbox() === $y->unbox()); } return IBool\Type::false(); }
/** * This method returns a value as a boxed object. A value is typically a PHP typed * primitive or object. It is considered type-safe. * * @access public * @static * @param mixed $value the value(s) to be boxed * @return IBool\Type the boxed object */ public static function make($value) : IBool\Type { if (is_string($value) && in_array(strtolower($value), array('false', 'f', 'no', 'n', '0', 'null', 'nil'))) { return IBool\Type::false(); } return $value ? IBool\Type::true() : IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IHashMap\Type $xs the left operand * @param Core\Type $ys the right operand * @return IBool\Type whether the left operand is identical * to the right operand */ public static function id(IHashMap\Type $xs, Core\Type $ys) : IBool\Type { // === if ($ys !== null && $xs->__typeOf() === $ys->__typeOf()) { if (IInt32\Module::eq($xs->size(), $ys->size())) { return IBool\Type::box((string) serialize($xs) == (string) serialize($ys)); } } return IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param ITuple\Type $xs the left operand * @param Core\Type $ys the right operand * @return IBool\Type whether the left operand is identical * to the right operand */ public static function id(ITuple\Type $xs, Core\Type $ys) : IBool\Type { // === if ($xs->__typeOf() === $ys->__typeOf()) { return IBool\Type::box(ITuple\Module::compare($xs, $ys)->unbox() == 0); } return IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IRatio\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(IRatio\Type $x, Core\Type $y) : IBool\Type { // === if ($x->__typeOf() === $y->__typeOf()) { return IBool\Module::and_(IInt32\Module::id($x->numerator(), $y->numerator()), IInt32\Module::id($x->denominator(), $y->denomintor())); } return IBool\Type::false(); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param IArrayList\Type $xs the left operand * @param Core\Type $ys the right operand * @return IBool\Type whether the left operand is identical * to the right operand */ public static function id(IArrayList\Type $xs, Core\Type $ys) : IBool\Type { // === if ($ys !== null) { if ($xs->__typeOf() === $ys->__typeOf()) { $x_length = $xs->__length(); $y_length = $ys->__length(); for ($i = 0; $i < $x_length && $i < $y_length; $i++) { $p = IInt32\Type::box($i); $r = $xs->item($p)->id($ys->item($p)); if (!$r->unbox()) { return $r; } } return IBool\Type::box($x_length == $y_length); } } return IBool\Type::false(); }
/** * This method tests the "singletons" methods. */ public function test_singletons() { $p0 = IBool\Type::true(); $e0 = IBool\Type::true(); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $p0); $this->assertSame($e0->__hashCode(), $p0->__hashCode()); $p1 = $p0->unbox(); $e1 = true; $this->assertInternalType('boolean', $p1); $this->assertSame($e1, $p1); $p2 = IBool\Type::false(); $e2 = IBool\Type::false(); $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $p2); $this->assertSame($e2->__hashCode(), $p2->__hashCode()); $p3 = $p2->unbox(); $e3 = false; $this->assertInternalType('boolean', $p3); $this->assertSame($e3, $p3); }
/** * This method evaluates whether the left operand is identical to the right operand. * * @access public * @static * @param ILinkedList\Type $xs the left operand * @param Core\Type $ys the right operand * @return IBool\Type whether the left operand is identical * to the right operand */ public static function id(ILinkedList\Type $xs, Core\Type $ys) : IBool\Type { // === if ($ys !== null && $xs->__typeOf() == $ys->typeOf()) { for ($as = $xs, $bs = $ys; !$as->__isEmpty() && !$bs->__isEmpty(); $as = $as->tail(), $bs = $bs->tail()) { $r = $as->head()->id($bs->head()); if (!$r->unbox()) { return $r; } } $x_length = $xs->__length(); $y_length = $ys->__length(); if ($x_length == $y_length) { return IBool\Type::true(); } } return IBool\Type::false(); }