Completed
Pull Request — master (#5)
by Quim
04:42 queued 02:24
created

Task::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace Domain\Task;
4
5
use Domain\Queue\Message;
6
7
class Task implements Message
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var array
16
     */
17
    private $body;
18
19
    /**
20
     * @var int
21
     */
22
    private $delay;
23
24
    /**
25
     * Task constructor.
26
     * @param string $name
27
     * @param array $body
28
     * @param int $delay
29
     */
30
    public function __construct($name, array $body, $delay=0)
31
    {
32
        $this->name = $name;
33
        $this->body = $body;
34
        $this->delay = $delay;
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getName()
41
    {
42
        return $this->name;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getBody()
49
    {
50
        return $this->body;
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getDelay()
57
    {
58
        return $this->delay;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function jsonSerialize()
65
    {
66
        return [
67
            'name' => $this->name,
68
            'body' => $this->body,
69
            'delay' => $this->delay
70
        ];
71
    }
72
}