2017 © Pedro Peláez
 

library httpstream

Kambo httpstream additional streams for the PSR-7

image

kambo/httpstream

Kambo httpstream additional streams for the PSR-7

  • Saturday, August 13, 2016
  • by kambo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

kambo httpstream

Build Status Scrutinizer Code Quality Code Coverage Software License, (*1)

Implementation of additional streams for the PSR-7 - HTTP message interfaces, (*2)

Stream implementation

This package comes with a following stream implementations: - string stream - callback stream, (*3)

Each of these stream offers additional functionality not provided by original PSR-7 stream implementations., (*4)

Install

Prefered way to install library is with composer:, (*5)

composer require kambo/httpstream

Basic usage

StringStream

String stream is simple synthetic sugar that allows instantiation of stream from the string. Implementation create temporary resource which will be used as base for the StringStream and it is fully compatible with the PSR-7 stream., (*6)

$stringStream = new StringStream('foo');
$stringStream->getContents(); // returns 'foo'

CallbackStream

Callback stream provides a readonly stream wrapper around given callback function. Callback will be executed only once by invoking method getContents or by casting object into string. Result of function is not cached and whole stream is after callback invocation in unusable state. This gravely limit usage of methods tell, seek, rewind and read. They cannot be used and invoking any of them will throw exception., (*7)

$callback = function () {
    return 'bar';
};
$callbackStream = new CallbackStream($callback);
$callbackStream->getContents(); // Invoke function and returns 'bar'.
$callbackStream->getContents(); // stream is in detached state empty string ('') has been returned.

License

The MIT License (MIT), https://opensource.org/licenses/MIT, (*8)

The Versions

13/08 2016

dev-master

9999999-dev

Kambo httpstream additional streams for the PSR-7

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bohuslav Simek

psr-7 http streams httpmessage

13/08 2016

v0.9.0

0.9.0.0

Kambo httpstream additional streams for the PSR-7

  Sources   Download

MIT

The Requires

 

The Development Requires

by Bohuslav Simek

psr-7 http streams httpmessage