Author: Bert Peters (bert.ljpeters@gmail.com)
Inheritance: implements IteratorAggregat\IteratorAggregate, implements Countabl\Countable
Beispiel #1
0
 /**
  * Construct a new skipping stream.
  *
  * @param Traversable $source
  * @param int $toSkip The number of items to skip.
  * @throws InvalidArgumentException if the number to skip is less than 0.
  */
 public function __construct($source, $toSkip)
 {
     parent::__construct($source);
     if ($toSkip < 0) {
         throw new InvalidArgumentException("To skip should be >= 0.");
     }
     $this->toSkip = $toSkip;
 }
Beispiel #2
0
 /**
  * Construct a limited stream.
  *
  * @param type $source
  * @param type $limit The number of items to show, at most.
  * @throws InvalidArgumentException
  */
 public function __construct($source, $limit)
 {
     parent::__construct($source);
     if ($limit < 0) {
         throw new InvalidArgumentException("Limit should be at least 0.");
     }
     $this->limit = $limit;
 }
Beispiel #3
0
 public function testIsSortedWithArray()
 {
     $instance = new Stream([]);
     $this->assertFalse($instance->isSorted());
 }
 /**
  * Construct a new flatmap stream.
  *
  * @param iterable $source The source to read from.
  * @param callable $unpacker Some callback that convert source stream items
  * to something iterable.
  */
 public function __construct($source, callable $unpacker)
 {
     parent::__construct($source);
     $this->unpacker = $unpacker;
 }
 public function __construct($source, callable $callback)
 {
     parent::__construct($source);
     $this->callback = $callback;
 }
 public function __construct($source, callable $sort = null)
 {
     parent::__construct($source);
     $this->sort = $sort;
 }
 /**
  * Construct a unique stream.
  *
  * This stream will yield each distinct value only once.
  *
  * @param \Traversable $source
  * @param boolean $strict Whether to use strict comparisons when determining uniqueness.
  */
 public function __construct($source, $strict)
 {
     parent::__construct($source);
     $this->strict = $strict;
 }