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

Stat::getReceived()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace Loevgaard\Linkmobility\Response\BatchStatus;
3
4
use Loevgaard\Linkmobility\Exception\InvalidResponseException;
5
use Loevgaard\Linkmobility\Response\Response;
6
7
class Stat extends Response
8
{
9
    /**
10
     * @var \DateTimeImmutable
11
     */
12
    protected $sendTime;
13
14
    /**
15
     * @var int
16
     */
17
    protected $buffered;
18
19
    /**
20
     * @var int
21
     */
22
    protected $received;
23
24
    /**
25
     * @var int
26
     */
27
    protected $rejected;
28
29
    /**
30
     * @throws InvalidResponseException
31
     */
32 1
    public function init() : void
33
    {
34 1 View Code Duplication
        if (isset($this->data->sendtime)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35 1
            $this->sendTime = \DateTimeImmutable::createFromFormat('d-m-Y H:i:s', $this->data->sendtime);
36 1
            if ($this->sendTime === false) {
37
                throw new InvalidResponseException(
38
                    '`sendtime` does not have the correct format. Value given: '.$this->data->sendtime
39
                );
40
            }
41
        }
42
43 1
        if (isset($this->data->buffered)) {
44 1
            $this->buffered = (int)$this->data->buffered;
45
        }
46
47 1
        if (isset($this->data->received)) {
48 1
            $this->received = (int)$this->data->received;
49
        }
50
51 1
        if (isset($this->data->rejected)) {
52 1
            $this->rejected = (int)$this->data->rejected;
53
        }
54 1
    }
55
56
    /**
57
     * @return \DateTimeImmutable
58
     */
59 1
    public function getSendTime(): \DateTimeImmutable
60
    {
61 1
        return $this->sendTime;
62
    }
63
64
    /**
65
     * @return int
66
     */
67 1
    public function getBuffered(): int
68
    {
69 1
        return $this->buffered;
70
    }
71
72
    /**
73
     * @return int
74
     */
75 1
    public function getReceived(): int
76
    {
77 1
        return $this->received;
78
    }
79
80
    /**
81
     * @return int
82
     */
83 1
    public function getRejected(): int
84
    {
85 1
        return $this->rejected;
86
    }
87
}
88