EmitResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A __invoke() 0 4 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