RowEventBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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