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

Stat::getReceived()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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 \DateTimeInterface
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 3
    public function init()
30
    {
31 3 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...
32 3
            $this->sendTime = \DateTimeImmutable::createFromFormat('d-m-Y H:i:s', $this->data->sendtime);
33 3
            if($this->sendTime === false) {
34
                throw new InvalidResponseException('`sendtime` does not have the correct format. Value given: '.$this->data->sendtime);
35
            }
36
        }
37
38 3
        if(isset($this->data->buffered)) {
39 3
            $this->buffered = (int)$this->data->buffered;
40
        }
41
42 3
        if(isset($this->data->received)) {
43 3
            $this->received = (int)$this->data->received;
44
        }
45
46 3
        if(isset($this->data->rejected)) {
47 3
            $this->rejected = (int)$this->data->rejected;
48
        }
49 3
    }
50
51
    /**
52
     * @return \DateTimeInterface
53
     */
54
    public function getSendTime(): \DateTimeInterface
55
    {
56
        return $this->sendTime;
57
    }
58
59
    /**
60
     * @return int
61
     */
62
    public function getBuffered(): int
63
    {
64
        return $this->buffered;
65
    }
66
67
    /**
68
     * @return int
69
     */
70
    public function getReceived(): int
71
    {
72
        return $this->received;
73
    }
74
75
    /**
76
     * @return int
77
     */
78
    public function getRejected(): int
79
    {
80
        return $this->rejected;
81
    }
82
}
83