Test Setup Failed
Push — master ( 298fd3...56daff )
by Matthew
17:14
created

Job   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 48.15 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 1
dl 26
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDeliveryTag() 0 4 1
A setDeliveryTag() 0 4 1
A toMessage() 12 12 2
A fromMessage() 14 14 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 Dtc\QueueBundle\RabbitMQ;
4
5
class Job extends \Dtc\QueueBundle\Model\Job
6
{
7
    protected $deliveryTag;
8
9
    /**
10
     * @return mixed
11
     */
12
    public function getDeliveryTag()
13
    {
14
        return $this->deliveryTag;
15
    }
16
17
    /**
18
     * @param mixed $deliveryTag
19
     */
20
    public function setDeliveryTag($deliveryTag)
21
    {
22
        $this->deliveryTag = $deliveryTag;
23
    }
24
25
    /**
26
     * @return string A json_encoded version of a queueable version of the object
27
     */
28 View Code Duplication
    public function toMessage()
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...
29
    {
30
        $arr = array(
31
            'args' => $this->getArgs(),
32
            'id' => $this->getId(),
33
            'expiresAt' => ($expiresAt = $this->getExpiresAt()) ? $expiresAt->getTimestamp() : null,
34
            'method' => $this->getMethod(),
35
            'worker' => $this->getWorkerName(),
36
        );
37
38
        return json_encode($arr);
39
    }
40
41
    /**
42
     * @param string $message a json_encoded version of the object
43
     */
44 View Code Duplication
    public function fromMessage($message)
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...
45
    {
46
        $arr = json_decode($message, true);
47
        $this->setArgs($arr['args']);
48
        $this->setId($arr['id']);
49
        $this->setMethod($arr['method']);
50
        $this->setWorkerName($arr['worker']);
51
        $expiresAt = $arr['expiresAt'];
52
        if ($expiresAt) {
53
            $dateTime = new \DateTime();
54
            $dateTime->setTimestamp(intval($expiresAt));
55
            $this->setExpiresAt($dateTime);
56
        }
57
    }
58
}
59