Completed
Pull Request — master (#5)
by Pavel
11:51
created

PsrResponder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Lamoda\Metric\Responder;
4
5
use Lamoda\Metric\Collector\MetricCollectorInterface;
6
use Psr\Http\Message\ResponseInterface;
7
8
final class PsrResponder
9
{
10
    /**
11
     * @var MetricCollectorInterface
12
     */
13
    private $collector;
14
    /**
15
     * @var ResponseFactoryInterface
16
     */
17
    private $factory;
18
    /**
19
     * @var array
20
     */
21
    private $options;
22
23 1
    public function __construct(
24
        MetricCollectorInterface $collector,
25
        ResponseFactoryInterface $factory,
26
        array $options = []
27
    ) {
28 1
        $this->collector = $collector;
29 1
        $this->factory = $factory;
30 1
        $this->options = $options;
31 1
    }
32
33
    /**
34
     * Create PSR-7 HTTP response for collected metrics
35
     *
36
     * @return ResponseInterface
37
     */
38 1
    public function createResponse(): ResponseInterface
39
    {
40 1
        return $this->factory->create($this->collector->collect(), $this->options);
41
    }
42
}
43