2017 © Pedro Peláez
 

library stdin-iterator

Iterator to read STDIN line by line

image

hikaeme/stdin-iterator

Iterator to read STDIN line by line

  • Saturday, June 3, 2017
  • by fjyuu
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Stdin Iterator

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);
    }
}

The Versions

03/06 2017

dev-master

9999999-dev

Iterator to read STDIN line by line

  Sources   Download

MIT

The Development Requires

by Yuki Fujii

03/06 2017

1.1.0

1.1.0.0

Iterator to read STDIN line by line

  Sources   Download

MIT

The Development Requires

by Yuki Fujii

02/06 2017

1.0.0

1.0.0.0

Iterator to read STDIN line by line

  Sources   Download

MIT

by Yuki Fujii