Passed
Push — master ( 767d18...65c593 )
by Ekin
11:48
created

Factory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A build() 0 3 1
A buildFromResponse() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace ekinhbayar\GitAmp\Response;
4
5
use Amp\Promise;
6
use ekinhbayar\GitAmp\Event\Factory as EventFactory;
7
use Amp\Http\Client\Response;
8
use Psr\Log\LoggerInterface;
9
use function Amp\call;
10
11
class Factory
12
{
13
    private EventFactory $eventFactory;
14
15
    private LoggerInterface $logger;
16
17 3
    public function __construct(EventFactory $eventFactory, LoggerInterface $logger)
18
    {
19 3
        $this->eventFactory = $eventFactory;
20 3
        $this->logger       = $logger;
21 3
    }
22
23 3
    public function build(): Results
24
    {
25 3
        return new Results($this->eventFactory, $this->logger);
26
    }
27
28 2
    public function buildFromResponse(string $eventNamespace, Response $response): Promise
29
    {
30 2
        return call(function() use ($eventNamespace, $response) {
31 2
            $results = $this->build();
32
33 2
            yield $results->appendResponse($eventNamespace, $response);
34
35 2
            return $results;
36 2
        });
37
    }
38
}
39