Passed
Push — master ( a86aba...ac3ce9 )
by Alexey
09:52
created

ResponseEmitter::emitBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1.0156

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 4
cp 0.75
crap 1.0156
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Venta\Http;
4
5
use Psr\Http\Message\ResponseInterface;
6
use Venta\Contracts\Http\ResponseEmitter as ResponseEmitterContract;
7
use Zend\Diactoros\Response\SapiEmitter;
8
use Zend\Diactoros\Response\SapiEmitterTrait;
9
10
/**
11
 * Class Emitter
12
 *
13
 * @package Venta\Http
14
 */
15
final class ResponseEmitter extends SapiEmitter implements ResponseEmitterContract
16
{
17
    use SapiEmitterTrait;
18
19
    /**
20
     * Emits a response for a PHP SAPI environment.
21
     *
22
     * Emits the status line and headers via the header() function, and the
23
     * body content via the output buffer.
24
     *
25
     * @param ResponseInterface $response
26
     * @param null|int $maxBufferLevel Maximum output buffering level to unwrap.
27
     */
28 3
    public function emit(ResponseInterface $response, $maxBufferLevel = null)
29
    {
30 3
        if (!headers_sent()) {
31 1
            $this->emitStatusLine($response);
32 1
            $this->emitHeaders($response);
33
        }
34 3
        $this->flush($maxBufferLevel);
35 3
        $this->emitBody($response);
36 3
    }
37
38
    /**
39
     * Emit the message body.
40
     *
41
     * @param ResponseInterface $response
42
     */
43 3
    private function emitBody(ResponseInterface $response)
0 ignored issues
show
Bug introduced by
Consider using a different method name as you override a private method of the parent class.

Overwriting private methods is generally fine as long as you also use private visibility. It might still be preferable for understandability to use a different method name.

Loading history...
44
    {
45 3
        echo $response->getBody();
46
    }
47
}