Completed
Push — master ( a8687a...737d23 )
by Joachim
07:33
created

BatchStatusResponse::init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
crap 2
1
<?php declare(strict_types=1);
2
namespace Loevgaard\Linkmobility\Response;
3
4
use Assert\Assert;
5
use Loevgaard\Linkmobility\Response\BatchStatusResponse\Details;
6
use Loevgaard\Linkmobility\Response\BatchStatusResponse\Stat;
7
8
class BatchStatusResponse extends Response
9
{
10
    /**
11
     * @var Stat
12
     */
13
    protected $stat;
14
15
    /**
16
     * @var Details
17
     */
18
    protected $details;
19
20
    /**
21
     * @var int
22
     */
23
    protected $status;
24
25 1
    public function init() : void
26
    {
27 1
        Assert::that($this->data)
28 1
            ->isArray()
29 1
            ->keyExists('status')
30 1
            ->keyExists('stat')
31 1
            ->keyExists('details')
32
        ;
33
34 1
        $this->status = (int)$this->data['status'];
35 1
        $this->stat = new Stat($this->data['stat']);
36 1
        $this->details = new Details($this->data['details']);
37
38 1
        $this->successful = $this->status >= 200 && $this->status < 300;
39 1
    }
40
41
    /**
42
     * @return Stat
43
     */
44 1
    public function getStat(): Stat
45
    {
46 1
        return $this->stat;
47
    }
48
49
    /**
50
     * @return Details
51
     */
52 1
    public function getDetails(): Details
53
    {
54 1
        return $this->details;
55
    }
56
57
    /**
58
     * @return int
59
     */
60 1
    public function getStatus(): int
61
    {
62 1
        return $this->status;
63
    }
64
}
65