Task   A
last analyzed

Complexity

Total Complexity 18

Size/Duplication

Total Lines 155
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 18
lcom 0
cbo 2
dl 0
loc 155
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0

17 Methods

Rating   Name   Duplication   Size   Complexity  
A id() 0 4 1
A state() 0 4 1
A started() 0 4 1
A startTime() 0 3 1
A body() 0 9 2
A hidden() 0 4 1
A description() 0 4 1
A result() 0 4 1
A completed() 0 4 1
A completedTime() 0 3 1
A created() 0 5 1
A queue() 0 4 1
A cookie() 0 4 1
A recipient() 0 4 1
A sender() 0 4 1
A percentage() 0 4 1
A logs() 0 3 1
1
<?php
2
3
namespace Acquia\Cloud\Api\Response;
4
5
use Acquia\Json\Json;
6
7
class Task extends \Acquia\Rest\Element
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $idColumn = 'id';
13
14
    /**
15
     * @return string
16
     */
17 66
    public function id()
18
    {
19 66
        return $this['id'];
20
    }
21
22
    /**
23
     * @return string
24
     */
25 66
    public function state()
26
    {
27 66
        return $this['state'];
28
    }
29
30
    /**
31
     * @return boolean
32
     */
33 66
    public function started()
34
    {
35 66
        return !empty($this['started']);
36
    }
37
38
    /**
39
     * Gets the Unix timestamp indicating when this task was started.
40
     *
41
     * @return int
42
     *   The Unix timestamp.
43
     */
44 66
    public function startTime() {
45 66
        return intval($this['started']);
46
    }
47
48
    /**
49
     * @return string|array
50
     */
51 66
    public function body()
52
    {
53 66
        if (preg_match('/^[\[{]/', $this['body'])) {
54 60
            return Json::decode($this['body']);
55
        } else {
56 6
            return $this['body'];
57
        }
58
59
    }
60
61
    /**
62
     * @return boolean
63
     */
64 66
    public function hidden()
65
    {
66 66
        return !empty($this['hidden']);
67
    }
68
69
    /**
70
     * @return string
71
     */
72 66
    public function description()
73
    {
74 66
        return $this['description'];
75
    }
76
77
    /**
78
     * @return string
79
     */
80 66
    public function result()
81
    {
82 66
        return $this['result'];
83
    }
84
85
    /**
86
     * @return boolean
87
     */
88 66
    public function completed()
89
    {
90 66
        return !empty($this['completed']);
91
    }
92
93
    /**
94
     * Gets the Unix timestamp indicating when this task was completed.
95
     *
96
     * @return int
97
     *   The Unix timestamp.
98
     */
99 66
    public function completedTime() {
100 66
        return intval($this['completed']);
101
    }
102
103
    /**
104
     * @return \DateTime
105
     */
106 66
    public function created()
107
    {
108 66
        $created = new \DateTime();
109 66
        return $created->setTimestamp($this['created']);
110
    }
111
112
    /**
113
     * @return string
114
     */
115 66
    public function queue()
116
    {
117 66
        return $this['queue'];
118
    }
119
120
    /**
121
     * @return array
122
     */
123 66
    public function cookie()
124
    {
125 66
        return Json::decode($this['cookie']);
126
    }
127
128
    /**
129
     * @return string
130
     */
131 66
    public function recipient()
132
    {
133 66
        return $this['recipient'];
134
    }
135
136
    /**
137
     * @return string
138
     */
139 66
    public function sender()
140
    {
141 66
        return $this['sender'];
142
    }
143
144
    /**
145
     * @return percentage
146
     */
147 66
    public function percentage()
148
    {
149 66
        return $this['percentage'];
150
    }
151
152
    /**
153
     * Gets the task log data.
154
     *
155
     * @return string
156
     *   The log data.
157
     */
158 6
    public function logs() {
159 6
        return $this['logs'];
160
    }
161
}
162