Completed
Push — master ( d8ae00...12ed8a )
by Tobias
02:18
created

TotalResponseItem::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 12
cts 12
cp 1
rs 9.7666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2013 Mailgun
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license. See the LICENSE file for details.
10
 */
11
12
namespace Mailgun\Model\Stats;
13
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17
final class TotalResponseItem
18
{
19
    private $time;
20
    private $accepted;
21
    private $delivered;
22
    private $failed;
23
    private $complained;
24
    private $opened;
25
    private $clicked;
26
    private $unsubscribed;
27
    private $stored;
28
29 8
    public static function create(array $data): self
30
    {
31 8
        $model = new self();
32 8
        $model->time = isset($data['time']) ? new \DateTimeImmutable($data['time']) : null;
33 8
        $model->accepted = $data['accepted'] ?? [];
34 8
        $model->delivered = $data['delivered'] ?? [];
35 8
        $model->failed = $data['failed'] ?? [];
36 8
        $model->complained = $data['complained'] ?? [];
37 8
        $model->opened = $data['opened'] ?? [];
38 8
        $model->clicked = $data['clicked'] ?? [];
39 8
        $model->unsubscribed = $data['unsubscribed'] ?? [];
40 8
        $model->stored = $data['stored'] ?? [];
41
42 8
        return $model;
43
    }
44
45 8
    private function __construct()
46
    {
47 8
    }
48
49 1
    public function getTime(): ?\DateTimeImmutable
50
    {
51 1
        return $this->time;
52
    }
53
54 1
    public function getAccepted(): array
55
    {
56 1
        return $this->accepted;
57
    }
58
59 1
    public function getDelivered(): array
60
    {
61 1
        return $this->delivered;
62
    }
63
64 1
    public function getFailed(): array
65
    {
66 1
        return $this->failed;
67
    }
68
69 1
    public function getComplained(): array
70
    {
71 1
        return $this->complained;
72
    }
73
74 1
    public function getOpened(): array
75
    {
76 1
        return $this->opened;
77
    }
78
79 1
    public function getClicked(): array
80
    {
81 1
        return $this->clicked;
82
    }
83
84 1
    public function getUnsubscribed(): array
85
    {
86 1
        return $this->unsubscribed;
87
    }
88
89 1
    public function getStored(): array
90
    {
91 1
        return $this->stored;
92
    }
93
}
94