Completed
Push — master ( 8f139f...a8687a )
by Joachim
04:58
created

BatchStatus   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 3
dl 0
loc 66
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 14 4
A isSuccessful() 0 4 2
A getStat() 0 4 1
A getDetails() 0 4 1
A getStatus() 0 4 1
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 1
    public function init() : void
25
    {
26 1
        if (isset($this->data->status)) {
27 1
            $this->status = (int)$this->data->status;
28
        }
29
30 1
        if (isset($this->data->stat)) {
31 1
            $this->stat = new Stat($this->data->stat);
32
        }
33
34 1
        if (isset($this->data->details)) {
35 1
            $this->details = new Details($this->data->details);
36
        }
37 1
    }
38
39
    /**
40
     * Returns true if the request was successful
41
     *
42
     * @return bool
43
     */
44
    public function isSuccessful()
45
    {
46
        return $this->status >= 200 && $this->status < 300;
47
    }
48
49
    /**
50
     * @return Stat
51
     */
52 1
    public function getStat(): Stat
53
    {
54 1
        return $this->stat;
55
    }
56
57
    /**
58
     * @return Details
59
     */
60 1
    public function getDetails(): Details
61
    {
62 1
        return $this->details;
63
    }
64
65
    /**
66
     * @return int
67
     */
68 1
    public function getStatus(): int
69
    {
70 1
        return $this->status;
71
    }
72
}
73