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

QueuedLoader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A load() 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\Loader;
4
5
use Ko\AmqpBroker;
6
7 View Code Duplication
class QueuedLoader extends AutoFlushLoader implements LoaderInterface
8
{
9
    private $loader;
10
    private $broker;
11
    private $consumer;
12
13
    public function __construct(LoaderInterface $loader, AmqpBroker $broker, $consumer)
14
    {
15
        $this->loader = $loader;
16
        $this->broker = $broker;
17
        $this->consumer = $consumer;
18
    }
19
20
    public function load($data = null)
21
    {
22
        $this->broker->getConsumer($this->consumer)->consume([$this->loader, 'load'], AMQP_AUTOACK);
23
    }
24
}
25