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

Job::setDeliveryTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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