Code Duplication    Length = 41-42 lines in 2 locations

src/mappers/JobBindingToExchangeDeleteMapper.php 1 location

@@ 12-52 (lines=41) @@
9
use mcorten87\rabbitmq_api\objects\Url;
10
use mcorten87\rabbitmq_api\services\MqManagementConfig;
11
12
class JobBindingToExchangeDeleteMapper extends BaseMapper
13
{
14
    protected function mapMethod(JobBase $job) : Method
15
    {
16
        return new Method(Method::METHOD_DELETE);
17
    }
18
19
    /**
20
     * @param JobBindingToExchangeCreate $job
21
     * @return Url
22
     */
23
    protected function mapUrl(JobBase $job) : Url
24
    {
25
        return new Url('bindings/'
26
            .urlencode($job->getVirtualHost()).'/'
27
            .'e/'
28
            .urlencode($job->getExchangeName()).'/'
29
            .$job->getDestinationType().'/'
30
            .urlencode($job->getToExchange())
31
            .'/'.(!empty((string) $job->getRoutingKey()) ? (string) $job->getRoutingKey() : '~')
32
        );
33
    }
34
35
    /**
36
     * @param JobBindingToExchangeCreate $job
37
     * @return array
38
     */
39
    protected function mapConfig(JobBase $job) : array {
40
        $body = [
41
            'destination'       => (string)$job->getToExchange(),
42
            'destination_type'  => $job->getDestinationType(),
43
            'properties_key'       => (string)$job->getRoutingKey(),
44
            'source'            => (string)$job->getExchangeName(),
45
            'vhost'             => $job->getVirtualHost(),
46
        ];
47
48
        return array_merge(parent::mapConfig($job), [
49
            'json'      =>  $body,
50
        ]);
51
    }
52
}
53

src/mappers/JobBindingToQueueDeleteMapper.php 1 location

@@ 12-53 (lines=42) @@
9
use mcorten87\rabbitmq_api\objects\Url;
10
use mcorten87\rabbitmq_api\services\MqManagementConfig;
11
12
class JobBindingToQueueDeleteMapper extends BaseMapper
13
{
14
    protected function mapMethod(JobBase $job) : Method
15
    {
16
        return new Method(Method::METHOD_DELETE);
17
    }
18
19
    /**
20
     * @param JobBindingToExchangeCreate $job
21
     * @return Url
22
     */
23
    protected function mapUrl(JobBase $job) : Url
24
    {
25
        return new Url('bindings/'
26
            .urlencode($job->getVirtualHost()).'/'
27
            .'e/'
28
            .urlencode($job->getExchangeName()).'/'
29
            .$job->getDestinationType().'/'
30
            .urlencode($job->getQueueName())
31
            .'/'.(!empty((string) $job->getRoutingKey()) ? (string) $job->getRoutingKey() : '~')
32
        );
33
    }
34
35
    /**
36
     * @param JobBindingToExchangeCreate $job
37
     * @return array
38
     */
39
    protected function mapConfig(JobBase $job) : array {
40
        $body = [
41
            'arguments'         => [],
42
            'destination'       => (string)$job->getQueueName(),
43
            'destination_type'  => $job->getDestinationType(),
44
            'routing_key'       => (string)$job->getRoutingKey(),
45
            'source'            => (string)$job->getExchangeName(),
46
            'vhost'             => $job->getVirtualHost(),
47
        ];
48
49
        return array_merge(parent::mapConfig($job), [
50
            'json'      =>  $body,
51
        ]);
52
    }
53
}
54