Completed
Pull Request — master (#19)
by Michal
03:25
created

RabbitMQHeaderManager   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 50.88 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 29
loc 57
ccs 45
cts 45
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A databasesHeaders() 13 13 1
A tablesHeaders() 16 16 1
A itemsHeaders() 0 23 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 Adminerng\Drivers\RabbitMQ;
4
5
use Adminerng\Core\Column;
6
use Adminerng\Core\ListingHeaders\HeaderManagerInterface;
7
8
class RabbitMQHeaderManager implements HeaderManagerInterface
9
{
10 2 View Code Duplication
    public function databasesHeaders()
0 ignored issues
show
Duplication introduced by
This method 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...
11
    {
12 2
        $columns = [];
13 2
        $columns[] = (new Column('vhost', 'rabbitmq.headers.vhosts.vhost'))
14 2
            ->setSortable(true);
15 2
        $columns[] = (new Column('queues', 'rabbitmq.headers.vhosts.queues'))
16 2
            ->setSortable(true)
17 2
            ->setNumeric(true);
18 2
        $columns[] = (new Column('messages', 'rabbitmq.headers.vhosts.messages'))
19 2
            ->setSortable(true)
20 2
            ->setNumeric(true);
21 2
        return $columns;
22
    }
23
24 2 View Code Duplication
    public function tablesHeaders()
0 ignored issues
show
Duplication introduced by
This method 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...
25
    {
26 2
        $columns = [];
27 2
        $columns[] = (new Column('queue', 'rabbitmq.headers.queues.queue'))
28 2
            ->setSortable(true);
29 2
        $columns[] = (new Column('number_of_items', 'rabbitmq.headers.queues.number_of_items'))
30 2
            ->setSortable(true)
31 2
            ->setNumeric(true);
32 2
        $columns[] = (new Column('size', 'rabbitmq.headers.queues.size'))
33 2
            ->setSortable(true)
34 2
            ->setNumeric(true)
35 2
            ->setSize(true);
36
        return [
37 2
            RabbitMQDriver::TYPE_QUEUE => $columns,
38 1
        ];
39
    }
40
41 2
    public function itemsHeaders($type, $table)
42
    {
43 2
        $columns = [];
44 2
        if ($type == RabbitMQDriver::TYPE_QUEUE) {
45 2
            $columns[] = (new Column('message_body', 'rabbitmq.columns.' . $type . '.message_body'))
46 2
                ->setSortable(true)
47 2
                ->setFilterable(true);
48 2
            $columns[] = (new Column('length', 'rabbitmq.columns.' . $type . '.length'))
49 2
                ->setNumeric(true)
50 2
                ->setSortable(true)
51 2
                ->setFilterable(true);
52 2
            $columns[] = (new Column('is_truncated', 'rabbitmq.columns.' . $type . '.is_truncated'))
53 2
                ->setSortable(true)
54 2
                ->setFilterable(true);
55 2
            $columns[] = (new Column('content_encoding', 'rabbitmq.columns.' . $type . '.content_encoding'))
56 2
                ->setSortable(true)
57 2
                ->setFilterable(true);
58 2
            $columns[] = (new Column('redelivered', 'rabbitmq.columns.' . $type . '.redelivered'))
59 2
                ->setSortable(true)
60 2
                ->setFilterable(true);
61 1
        }
62 2
        return $columns;
63
    }
64
}
65