phpstreams\Stream::__construct PHP Méthode

__construct() public méthode

Construct a new stream from a traversable source.
public __construct ( Traversabl\Traversable | array $source )
$source Traversabl\Traversable | array The source to create the stream from.
    public function __construct($source)
    {
        if (!static::isValidSource($source)) {
            throw new InvalidStreamException();
        }
        $this->source = $source;
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of phpstreams\Stream::__construct