Esempio n. 1
0
 /**
  * Returns an optional value that has a value of the given argument if the given boolean is true, otherwise,
  * returns no value
  *
  * @param bool $p
  * @param $value
  * @return Option
  */
 public static function iif(bool $p, $value) : Option
 {
     if ($p == true) {
         return Option::some($value);
     }
     return Option::none();
 }
Esempio n. 2
0
 public function test_toNull()
 {
     $this->assertNull(Option::none()->toNull());
     $this->assertEquals($this->helloWorld, Option::some($this->helloWorld)->toNull());
 }