EmitResponse::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
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