1
0
Fork 0

Add ArrayIO helper to capture output

pull/1283/head
Jordi Boggiano 2012-11-02 18:13:08 +01:00
parent bb701da8c2
commit 6549360dac
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\IO;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Helper\HelperSet;
/**
* The Input/Output helper.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class ArrayIO extends ConsoleIO
{
/**
* @param string $input
* @param int $verbosity
*/
public function __construct($input = '', $verbosity = null)
{
$input = new StringInput($input);
$input->setInteractive(false);
// TODO pass a custom output formatter for html tags
$output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity === null ? StreamOutput::VERBOSITY_NORMAL : $verbosity, false);
parent::__construct($input, $output, new HelperSet(array()));
}
public function getOutput()
{
fseek($this->output->getStream(), 0);
return stream_get_contents($this->output->getStream());
}
}