Ejemplo n.º 1
0
 /**
  * Tests that the map function will return an instance of None
  * if the callable passed returns None
  */
 public function testMapReturnsAbsentOnAbsent()
 {
     $present = $this->getPresent();
     $mapped = $present->map(function ($string) {
         return Optional::absent();
     });
     $this->assertInstanceOf('Bart\\Optional\\None', $mapped);
 }
Ejemplo n.º 2
0
 public function testAbsent()
 {
     $absent = Optional::absent();
     $this->assertInstanceOf('Bart\\Optional\\None', $absent);
 }
Ejemplo n.º 3
0
 /**
  * Returns an Optional containing the result of calling $callable on
  * the contained value. If no value exists, as in the case of None, then
  * this method will simply return None. The method will return None
  * if the result of applying $callable to the contained value is null.
  * @param callable $callable
  * @return Some|None
  */
 public function map(callable $callable)
 {
     return Optional::absent();
 }