Completed
Push — master ( 86c904...8f139f )
by Joachim
13:37
created

BatchStatus::getStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Loevgaard\Linkmobility\Response;
3
4
use Loevgaard\Linkmobility\Response\BatchStatus\Details;
5
use Loevgaard\Linkmobility\Response\BatchStatus\Stat;
6
7
class BatchStatus extends Response
8
{
9
    /**
10
     * @var Stat
11
     */
12
    protected $stat;
13
14
    /**
15
     * @var Details
16
     */
17
    protected $details;
18
19
    /**
20
     * @var int
21
     */
22
    protected $status;
23
24 6
    public function init()
25
    {
26 6
        parent::init();
27
28 6
        if (isset($this->data->status)) {
29 3
            $this->status = (int)$this->data->status;
30
        }
31
32 6
        if (isset($this->data->stat)) {
33 3
            $this->stat = new Stat($this->data->stat);
34
        }
35
36 6
        if (isset($this->data->details)) {
37 3
            $this->details = new Details($this->data->details);
38
        }
39 6
    }
40
41
    /**
42
     * Returns true if the request was successful
43
     *
44
     * @return bool
45
     */
46
    public function isSuccessful()
47
    {
48
        return $this->status >= 200 && $this->status < 300;
49
    }
50
51
    /**
52
     * @return Stat
53
     */
54
    public function getStat(): Stat
55
    {
56
        return $this->stat;
57
    }
58
59
    /**
60
     * @return Details
61
     */
62
    public function getDetails(): Details
63
    {
64
        return $this->details;
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getStatus(): int
71
    {
72
        return $this->status;
73
    }
74
}
75