Passed
Pull Request — master (#4)
by Tomasz
04:04
created

Producer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
declare(strict_types = 1);
13
14
namespace Aggrego\DomainEventProducer\EventConsumer;
15
16
use Aggrego\DomainEventProducer\Domain\Repository;
17
use Aggrego\EventConsumer\Client;
18
19
class Producer
20
{
21
    /**
22
     * @var Repository
23
     */
24
    private $repository;
25
26
    /**
27
     * @var Client
28
     */
29
    private $eventConsumer;
30
31
    public function __construct(Repository $repository, Client $eventConsumer)
32
    {
33
        $this->repository = $repository;
34
        $this->eventConsumer = $eventConsumer;
35
    }
36
37
    public function publish(): void
38
    {
39
        foreach ($this->repository->pullEvents() as $event) {
40
            $this->eventConsumer->consume($event);
41
        }
42
    }
43
}
44