Add ArrayIO helper to capture output
parent
bb701da8c2
commit
6549360dac
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue