Passed
Branch master (e090ea)
by kacper
04:22
created

RowEventFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 38
loc 38
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 1
A makeRowEvent() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace MySQLReplication\Event\RowEvent;
4
5
use MySQLReplication\BinaryDataReader\BinaryDataReader;
6
use MySQLReplication\Event\EventInfo;
7
use MySQLReplication\JsonBinaryDecoder\JsonBinaryDecoderFactory;
8
use MySQLReplication\Repository\RepositoryInterface;
9
use Psr\SimpleCache\CacheInterface;
10
11
/**
12
 * Class RowEventService
13
 * @package MySQLReplication\RowEvent
14
 */
15 View Code Duplication
class RowEventFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @var RowEventBuilder
19
     */
20
    private $rowEventBuilder;
21
22
    /**
23
     * RowEventService constructor.
24
     * @param RepositoryInterface $repository
25
     * @param JsonBinaryDecoderFactory $jsonBinaryDecoderFactory
26
     * @param CacheInterface $cache
27
     */
28 54
    public function __construct(
29
        RepositoryInterface $repository,
30
        JsonBinaryDecoderFactory $jsonBinaryDecoderFactory,
31
        CacheInterface $cache
32
    ) {
33 54
        $this->rowEventBuilder = new RowEventBuilder(
34 54
            $repository,
35 54
            $jsonBinaryDecoderFactory,
36
            $cache
37 54
        );
38 54
    }
39
40
    /**
41
     * @param BinaryDataReader $package
42
     * @param EventInfo $eventInfo
43
     * @return RowEvent
44
     */
45 52
    public function makeRowEvent(BinaryDataReader $package, EventInfo $eventInfo)
46
    {
47 52
        $this->rowEventBuilder->withPackage($package);
48 52
        $this->rowEventBuilder->withEventInfo($eventInfo);
49
50 52
        return $this->rowEventBuilder->build();
51
    }
52
}