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); }
public function map(callable $f) { return $this->has_value ? Option::some($f($this->value)) : Option::none(); }