mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-04 00:54:08 +02:00
Add Wrapper::wrap() convenience method
also fix some test class names
This commit is contained in:
parent
acb8b69108
commit
a19beaf7ef
5 changed files with 77 additions and 50 deletions
|
|
@ -7,7 +7,27 @@
|
|||
|
||||
namespace Icewind\Streams;
|
||||
|
||||
/**
|
||||
* Stream wrapper that does nothing, used for tests
|
||||
*/
|
||||
class NullWrapper extends Wrapper {
|
||||
/**
|
||||
* Wraps a stream with the provided callbacks
|
||||
*
|
||||
* @param resource $source
|
||||
* @return resource
|
||||
*/
|
||||
public static function wrap($source) {
|
||||
stream_wrapper_register('null', '\Icewind\Streams\NullWrapper');
|
||||
$context = stream_context_create(array(
|
||||
'null' => array(
|
||||
'source' => $source)
|
||||
));
|
||||
$wrapped = fopen('null://', 'r+', false, $context);
|
||||
stream_wrapper_unregister('null');
|
||||
return $wrapped;
|
||||
}
|
||||
|
||||
public function stream_open() {
|
||||
$this->loadContext('null');
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue