JobExchangeDeleteMapper::mapUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2.0116

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 10
loc 10
ccs 6
cts 7
cp 0.8571
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2.0116
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