Completed
Pull Request — master (#912)
by
unknown
07:49
created

TestCase   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOutputBuffer() 0 13 1
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util\Console\Helper\Table\Renderer;
9
10
use Symfony\Component\Console\Output\StreamOutput;
11
12
/**
13
 * Class RendererTestCase
14
 *
15
 * @package N98\Util\Console\Helper\Table\Renderer
16
 */
17
abstract class TestCase extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * helper method to get output as string out of a StreamOutput
21
     *
22
     * @param $output
23
     *
24
     * @return string all output
25
     */
26
    protected function getOutputBuffer(StreamOutput $output)
27
    {
28
        $handle = $output->getStream();
29
30
        rewind($handle);
31
        $display = stream_get_contents($handle);
32
33
        // Symfony2's StreamOutput has a hidden dependency on PHP_EOL which needs to be removed by
34
        // normalizing it to the standard newline for text here.
35
        $display = strtr($display, array(PHP_EOL => "\n"));
36
37
        return $display;
38
    }
39
}
40