twistor/stream-util

处理流数据的辅助工具。

v1.0.1 2015-06-12 11:33 UTC

This package is auto-updated.

Last update: 2024-08-26 08:54:47 UTC


README

Author Build Status Coverage Status Quality Score Software License Packagist Version

处理流数据的辅助函数。

安装

composer require twistor/stream-util

使用方法

use Twistor\StreamUtil;

$stream = fopen('php://temp', 'w+b');

fwrite($stream, 'asdfasfdas');

$cloned = StreamUtil::copy($stream, false); // Passing in true (the default),
                                            // will close the input stream.

StreamUtil::getSize($stream); // 10

StreamUtil::isAppendable($stream); // false

StreamUtil::isReadable($stream); // true

StreamUtil::isSeekable($stream); // true

StreamUtil::isWritable($stream); // true

StreamUtil::tryRewind($stream);  // true

StreamUtil::trySeek($stream, 0, SEEK_END); // true

// Metadata helpers.
StreamUtil::getMetaDataKey($stream, 'blocked') // false

StreamUtil::getUri($stream); // php://temp

StreamUtil::getUsuableUri($stream); // Returns a URI that can be used
                                    // with fopen().
                                    // false in this case.

// Mode helpers.
StreamUtil::modeIsAppendable('w+'); // false

StreamUtil::modeIsAppendOnly('a+'); // false

StreamUtil::modeIsReadable('w+');   // true

StreamUtil::modeIsReadOnly('r');    // true

StreamUtil::modeIsWritable('r+');   // true

StreamUtil::modeIsWriteOnly('w');   // true