some() public static method

public static some ( $thing )
Example #1
0
 public function testSomeFilter_WithMatched_ReturnsSome()
 {
     $expect = 13;
     $predicate = function ($input) {
         return true;
     };
     $ifSome = function ($input) use($expect) {
         return $input;
     };
     $ifNone = function () {
         $this->fail();
     };
     $actual = Option::some($expect)->filter($predicate)->match($ifSome, $ifNone);
     $this->assertEquals($expect, $actual);
 }
Example #2
0
 public function map(callable $f)
 {
     return $this->has_value ? Option::some($f($this->value)) : Option::none();
 }