hikaeme/stdin-iterator
Composer 安装命令:
composer require hikaeme/stdin-iterator
包简介
Iterator to read STDIN line by line
README 文档
README
Usage
use Hikaeme\StdinIterator; $stdin = new StdinIterator(); foreach ($stdin as $line) { echo $line; }
Installation
composer require hikaeme/stdin-iterator
Testable STDIN
class SampleCommand { private $stdin; public function __construct(StdinIterator $stdin = null) { $this->stdin = $stdin ?: new StdinIterator(); } public function run() { foreach ($this->stdin as $line) { echo $line; } } }
class SampleCommandTest extends \PHPUnit_Framework_TestCase { public function test() { $stub = new StdinIteratorStub(); $stub->setStdin("1\n2\n3\n"); $command = new \SampleCommand($stub); ob_start(); $command->run(); $result = ob_get_clean(); $this->assertSame("1\n2\n3\n", $result); } }
统计信息
- 总下载量: 190
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-02