Completed
Push — master ( 035a24...9f3c5b )
by
unknown
26s queued 21s
created

StdOutStream::emit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Common;
14
15
use GuzzleHttp\Psr7\StreamDecoratorTrait;
16
use Psr\Http\Message\StreamInterface;
17
use TYPO3\CMS\Core\Http\SelfEmittableStreamInterface;
18
19
/**
20
 * Stream decorator to allow printing a stream to standard output in chunks.
21
 */
22
class StdOutStream implements StreamInterface, SelfEmittableStreamInterface
23
{
24
    use StreamDecoratorTrait;
25
26
    public function emit()
27
    {
28
        // Disable output buffering
29
        ob_end_flush();
30
31
        // Stream content in chunks of 8KB
32
        while (!$this->stream->eof()) {
33
            echo $this->stream->read(8 * 1024);
34
        }
35
    }
36
}
37