RowEventBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
c 2
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace MySQLReplication\Event\RowEvent;
5
6
use MySQLReplication\BinaryDataReader\BinaryDataReader;
7
use MySQLReplication\Config\Config;
8
use MySQLReplication\Event\EventInfo;
9
use MySQLReplication\Repository\RepositoryInterface;
10
use Psr\SimpleCache\CacheInterface;
11
12
class RowEventBuilder
13
{
14
    private $repository;
15
    private $cache;
16
    /**
17
     * @var BinaryDataReader
18
     */
19
    private $package;
20
    /**
21
     * @var EventInfo
22
     */
23
    private $eventInfo;
24
    /**
25
     * @var Config
26
     */
27
    private $config;
28
29 58
    public function __construct(
30
        Config $config,
31
        RepositoryInterface $repository,
32
        CacheInterface $cache
33
    ) {
34 58
        $this->repository = $repository;
35 58
        $this->cache = $cache;
36 58
        $this->config = $config;
37
    }
38
39 54
    public function withPackage(BinaryDataReader $package): void
40
    {
41 54
        $this->package = $package;
42
    }
43
44 54
    public function build(): RowEvent
45
    {
46 54
        return new RowEvent(
47 54
            $this->config,
48 54
            $this->repository,
49 54
            $this->package,
50 54
            $this->eventInfo,
51 54
            $this->cache
52 54
        );
53
    }
54
55 54
    public function withEventInfo(EventInfo $eventInfo): void
56
    {
57 54
        $this->eventInfo = $eventInfo;
58
    }
59
}
60