JobExchangeDeleteMapper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 22
loc 22
ccs 8
cts 9
cp 0.8889
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mapMethod() 3 3 1
A mapUrl() 10 10 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
declare(strict_types=1);
3
namespace mcorten87\rabbitmq_api\mappers;
4
5
use mcorten87\rabbitmq_api\exceptions\WrongArgumentException;
6
use mcorten87\rabbitmq_api\jobs\JobBase;
7
use mcorten87\rabbitmq_api\jobs\JobExchangeDelete;
8
use mcorten87\rabbitmq_api\objects\Method;
9
use mcorten87\rabbitmq_api\objects\Url;
10
use mcorten87\rabbitmq_api\services\MqManagementConfig;
11
12 View Code Duplication
class JobExchangeDeleteMapper  extends BaseMapper
0 ignored issues
show
Coding Style introduced by
Expected 1 space after class name; 2 found
Loading history...
Coding Style introduced by
Expected 1 space before extends keyword; 2 found
Loading history...
Duplication introduced by
This class 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...
13
{
14
15 2
    protected function mapMethod() : Method {
16 2
        return new Method(Method::DELETE);
17
    }
18
19
    /**
20
     * @param JobExchangeDelete $job
21
     * @return Url
22
     */
23 2
    protected function mapUrl(JobBase $job) : Url {
24 2
        if (!$job instanceof JobExchangeDelete) {
25
            throw new WrongArgumentException($job, JobExchangeDelete::class);
26
        }
27
28 2
        $url = 'exchanges';
29 2
        $url .= '/'.urlencode((string)$job->getVirtualHost());
30 2
        $url .= '/'.urlencode((string)$job->getExchangeName());
31 2
        return new Url($url);
32
    }
33
}
34