Completed
Push — master ( 4cdc8a...86c904 )
by Joachim
01:27
created

BatchStatus::init()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 8
nop 0
dl 0
loc 16
ccs 9
cts 9
cp 1
crap 4
rs 9.2
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
        return $this->status >= 200 && $this->status < 300;
48
    }
49
}
50