Example #1
0
 protected function __construct($value)
 {
     if ($value instanceof \IteratorAggregate) {
         $value = $value->getIterator();
     } else {
         if (!$value instanceof \Traversable) {
             if (!is_array($value)) {
                 $value = [$value];
             }
             $value = new \ArrayIterator($value);
         }
     }
     parent::__construct($value);
 }
Example #2
0
File: Chain.php Project: iddqdby/f7
 /**
  * Apply function only if the value is not NULL.
  *
  * @see \monad\Monad::bind($function)
  * @see \monad\Chain::emptyChain()
  */
 public function continue(callable $function) : Chain
 {
     return parent::bind(conditionally(negation(is_null), $function));
 }
Example #3
0
 /**
  * {@inheritDoc}
  *
  * This is a closing operation (it calls <code>$this->close()</code> internally).
  *
  * @see \monad\Monad::extract()
  * @see \monad\Stream::close()
  */
 public function extract() : array
 {
     $value = parent::extract();
     $this->close();
     return $value;
 }