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

BatchStatus   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
dl 0
loc 43
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 4
A isSuccessful() 0 3 2
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