drupal-libraries / stream-util
处理流的有用工具。从twistor/stream-util分支并更新,以支持Flysystem 3.0+
v3.0.0
2024-04-19 00:55 UTC
Requires
- php: >=8.2
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpstan/phpstan: ^1.10
- phpunit/phpunit: >=9.0
README
处理流的有用函数。从原始库twistor/stream-util分支,并更新以兼容PHP8.2,以支持Flysystem v3.0+
安装
composer require drupal-libraries/stream-util
用法
use DrupalLibraries\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