Completed
Push — master ( 082b72...e854dc )
by Marco
01:52
created

EmitResponse::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marcosh\Effector\Effect\Http;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Zend\Diactoros\Response\EmitterInterface;
9
use Zend\Diactoros\Response\SapiEmitter;
10
11
final class EmitResponse
12
{
13
    /**
14
     * @var EmitterInterface|null
15
     */
16
    private $emitter;
17
18
    public function __construct(?EmitterInterface $emitter = null)
19
    {
20
        if (null === $emitter) {
21
            $emitter = new SapiEmitter();
22
        }
23
24
        $this->emitter = $emitter;
25
    }
26
27
    public function __invoke(ResponseInterface $response): void
28
    {
29
        $this->emitter->emit($response);
30
    }
31
}
32