Completed
Pull Request — master (#14)
by Саша
02:04
created

TransformerConsumer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 20
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A transform() 6 6 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 Extraload\Transformer;
4
5
use Ko\AmqpBroker;
6
7 View Code Duplication
class TransformerConsumer implements TransformerInterface
8
{
9
    private $transformer;
10
    private $broker;
11
    private $producer;
12
13
    public function __construct(TransformerInterface $transformer, AmqpBroker $broker, $producer)
14
    {
15
        $this->transformer = $transformer;
16
        $this->broker = $broker;
17
        $this->producer = $producer;
18
    }
19
20
    public function transform($data = null)
21
    {
22
        $this->broker->getProducer($this->producer)->publish(serialize(
23
            $this->transformer->transform($data)
24
        ));
25
    }
26
}
27