コード例 #1
0
ファイル: ModuleTest.php プロジェクト: bluesnowman/fphp-saber
 /**
  * This method tests the "and_" method.
  */
 public function test_and_()
 {
     $x = IBool\Type::true();
     $y = IBool\Type::false();
     $z = IBool\Module::and_($x, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(false, $z->unbox());
     $z = IBool\Module::and_($x, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(true, $z->unbox());
     $z = IBool\Module::and_($y, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(false, $z->unbox());
     $z = IBool\Module::and_($y, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IBool\\Type', $z);
     $this->assertSame(false, $z->unbox());
 }
コード例 #2
0
ファイル: Module.php プロジェクト: bluesnowman/fphp-saber
 /**
  * This method returns the first object in the collection that passes the truthy test, if any.
  *
  * @access public
  * @static
  * @param IOption\Type $xs                                  the left operand
  * @param callable $predicate                               the predicate function to be used
  * @return IOption\Type                                     an option containing the first object
  *                                                          satisfying the predicate, if any
  */
 public static function find(IOption\Type $xs, callable $predicate) : IOption\Type
 {
     if (IBool\Module::and_($xs->isDefined(), $predicate($xs->item(), IInt32\Type::zero()))->unbox()) {
         return $xs;
     }
     return IOption\Type::none();
 }
コード例 #3
0
ファイル: Module.php プロジェクト: bluesnowman/fphp-saber
 /**
  * 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();
 }