Inheritance: implements Countabl\Countable, implements IteratorAggregat\IteratorAggregate
Exemple #1
0
 public function testFromPredicate_WithUnmatched_ReturnsNone()
 {
     $expect = 13;
     $f = function ($input) {
         return false;
     };
     $ifSome = function ($input) {
         $this->fail();
     };
     $ifNone = function () use($expect) {
         return $expect;
     };
     $actual = Option::fromPredicate($f, $expect)->match($ifSome, $ifNone);
     $this->assertEquals($expect, $actual);
 }
Exemple #2
0
 public function map(callable $f)
 {
     return $this->has_value ? Option::some($f($this->value)) : Option::none();
 }