Stat   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 71
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSendTime() 0 4 1
A getBuffered() 0 4 1
A getReceived() 0 4 1
A getRejected() 0 4 1
A __construct() 0 16 1
1
<?php declare(strict_types=1);
2
namespace Loevgaard\Linkmobility\Response\BatchStatusResponse;
3
4
use Assert\Assert;
5
6
class Stat
7
{
8
    /**
9
     * @var \DateTimeImmutable
10
     */
11
    protected $sendTime;
12
13
    /**
14
     * @var int
15
     */
16
    protected $buffered;
17
18
    /**
19
     * @var int
20
     */
21
    protected $received;
22
23
    /**
24
     * @var int
25
     */
26
    protected $rejected;
27
28 1
    public function __construct(array $data)
29
    {
30 1
        Assert::that($data)
31 1
            ->isArray()->keyExists('sendtime')
32 1
            ->keyExists('buffered')
33 1
            ->keyExists('received')
34 1
            ->keyExists('rejected')
35
        ;
36
37 1
        $this->sendTime = \DateTimeImmutable::createFromFormat('d-m-Y H:i:s', $data['sendtime']);
38 1
        Assert::that($this->sendTime)->isInstanceOf(\DateTimeImmutable::class, '`sendtime` does not have the correct format. Value given: '.$data['sendtime']);
39
40 1
        $this->buffered = (int)$data['buffered'];
41 1
        $this->received = (int)$data['received'];
42 1
        $this->rejected = (int)$data['rejected'];
43 1
    }
44
45
    /**
46
     * @return \DateTimeImmutable
47
     */
48 1
    public function getSendTime(): \DateTimeImmutable
49
    {
50 1
        return $this->sendTime;
51
    }
52
53
    /**
54
     * @return int
55
     */
56 1
    public function getBuffered(): int
57
    {
58 1
        return $this->buffered;
59
    }
60
61
    /**
62
     * @return int
63
     */
64 1
    public function getReceived(): int
65
    {
66 1
        return $this->received;
67
    }
68
69
    /**
70
     * @return int
71
     */
72 1
    public function getRejected(): int
73
    {
74 1
        return $this->rejected;
75
    }
76
}
77