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

QueuedExtractor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A extract() 6 6 2

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\Extractor;
4
5
use Ko\AmqpBroker;
6
7 View Code Duplication
class QueuedExtractor implements ExtractorInterface
8
{
9
    private $extractor;
10
    private $broker;
11
    private $proucer;
12
13
    public function __construct(ExtractorIteratorInterface $extractor, AmqpBroker $broker, $proucer)
14
    {
15
        $this->extractor = $extractor;
16
        $this->broker = $broker;
17
        $this->proucer = $proucer;
18
    }
19
20
    public function extract()
21
    {
22
        while (null !== $extracted = $this->extractor->extract()) {
23
            $this->broker->getProducer($this->proucer)->publish(serialize($extracted));
24
        }
25
    }
26
}
27