示例#1
0
 /**
  * Adds an operation to a stream.
  *
  * @param  string $operation
  * @param  mixed $args
  * @param  Stream $stream
  * @return Stream
  */
 protected static function apply($operation, $args, $stream)
 {
     if ($stream->type == 'Error') {
         return Stream::of(Error::of("Could not apply {$operation} to {$stream->type}", $stream->data));
     }
     if (!Stream::canApply($operation, $stream->type)) {
         $data = toString($stream->data);
         return Stream::of(Error::of("Could not apply {$operation} to {$stream->type}({$data})"));
     }
     return Stream::with($stream->data, Stream::optimize(append(['name' => $operation, 'args' => $args], $stream->operations)), Stream::returnOf($operation, $stream->type));
 }