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

QueuedTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A transform() 4 4 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 QueuedTransformer implements TransformerInterface
8
{
9
    private $transformer;
10
    private $broker;
11
    private $consumer;
12
13
    public function __construct(TransformerConsumer $transformer, AmqpBroker $broker, $consumer)
14
    {
15
        $this->transformer = $transformer;
16
        $this->broker = $broker;
17
        $this->consumer = $consumer;
18
    }
19
20
    public function transform($data = null)
21
    {
22
        $this->broker->getConsumer($this->consumer)->consume([$this->transformer, 'transform'], AMQP_AUTOACK);
23
    }
24
}
25