Code Duplication    Length = 32-32 lines in 2 locations

src/mappers/JobQueueCreateMapper.php 1 location

@@ 12-43 (lines=32) @@
9
use mcorten87\rabbitmq_api\objects\Url;
10
use mcorten87\rabbitmq_api\services\MqManagementConfig;
11
12
class JobQueueCreateMapper extends BaseMapper
13
{
14
    protected function mapMethod(JobBase $job) : Method
15
    {
16
        return new Method(Method::METHOD_PUT);
17
    }
18
19
    protected function mapUrl(JobBase $job) : Url
20
    {
21
        return new Url('queues/'.urlencode($job->getVirtualHost()).'/'.urlencode($job->getQueueName()));
22
    }
23
24
    /**
25
     * @param JobQueueCreate $job
26
     * @return array
27
     */
28
    protected function mapConfig(JobBase $job) : array {
29
        $body = [
30
            'auto_delete'   => $job->isAutoDelete(),
31
            'durable'       => $job->isDurable(),
32
            'arguments'     => []
33
        ];
34
35
        foreach ($job->getArguments() as $argument) {
36
            $body['arguments'][$argument->getArgumentName()] = $argument->getValue();
37
        };
38
39
        return array_merge(parent::mapConfig($job), [
40
            'json'      =>  $body,
41
        ]);
42
    }
43
}
44

src/mappers/JobExchangeCreateMapper.php 1 location

@@ 11-42 (lines=32) @@
8
use mcorten87\rabbitmq_api\objects\Url;
9
use mcorten87\rabbitmq_api\services\MqManagementConfig;
10
11
class JobExchangeCreateMapper extends BaseMapper
12
{
13
    protected function mapMethod(JobBase $job) : Method
14
    {
15
        return new Method(Method::METHOD_PUT);
16
    }
17
18
    protected function mapUrl(JobBase $job) : Url
19
    {
20
        return new Url('exchanges/'.urlencode($job->getVirtualHost()).'/'.urlencode($job->getExchangeName()));
21
    }
22
23
    /**
24
     * @param JobExchangeCreate $job
25
     * @return array
26
     */
27
    protected function mapConfig(JobBase $job) : array {
28
        $body = [
29
            'auto_delete'   => $job->isAutoDelete(),
30
            'durable'       => $job->isDurable(),
31
            'arguments'     => []
32
        ];
33
34
        foreach ($job->getArguments() as $argument) {
35
            $body['arguments'][$argument->getArgumentName()] = $argument->getValue();
36
        };
37
38
        return array_merge(parent::mapConfig($job), [
39
            'json'      =>  $body,
40
        ]);
41
    }
42
}
43