Test Setup Failed
Pull Request — master (#46)
by Ekin
06:26
created

Factory::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 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;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
14
15
    private LoggerInterface $logger;
16
17 2
    public function __construct(EventFactory $eventFactory, LoggerInterface $logger)
18
    {
19 2
        $this->eventFactory = $eventFactory;
20 2
        $this->logger       = $logger;
21
    }
22
23 2
    public function build(string $eventNamespace, Response $response): Promise
24
    {
25 2
        return call(function() use ($eventNamespace, $response) {
26 2
            $results = new Results($this->eventFactory, $this->logger);
27
28 2
            yield from $results->appendResponse($eventNamespace, $response);
29
30 2
            return $results;
31 2
        });
32
    }
33
}
34