Completed
Push — master ( e67ef9...d5a49f )
by Tobias
03:42
created

StatisticsResponse   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 115
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 0
loc 115
ccs 0
cts 29
cp 0
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A create() 0 11 1
A getTag() 0 4 1
A getDescription() 0 4 1
A getResolution() 0 4 1
A getStart() 0 4 1
A getEnd() 0 4 1
A getStats() 0 4 1
1
<?php
2
3
/*
4
 * Copyright (C) 2013-2016 Mailgun
5
 *
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license. See the LICENSE file for details.
8
 */
9
10
namespace Mailgun\Resource\Api\Tag;
11
12
use Mailgun\Resource\ApiResponse;
13
14
/**
15
 * @author Tobias Nyholm <[email protected]>
16
 */
17
final class StatisticsResponse implements ApiResponse
18
{
19
    /**
20
     * @var string
21
     */
22
    private $tag;
23
24
    /**
25
     * @var string
26
     */
27
    private $description;
28
29
    /**
30
     * @var string
31
     */
32
    private $resolution;
33
34
    /**
35
     * @var \DateTime
36
     */
37
    private $start;
38
39
    /**
40
     * @var \DateTime
41
     */
42
    private $end;
43
44
    /**
45
     * @var array
46
     */
47
    private $stats;
48
49
    /**
50
     * @param string    $tag
51
     * @param string    $description
52
     * @param \DateTime $start
53
     * @param \DateTime $end
54
     * @param string    $resolution
55
     * @param array     $stats
56
     */
57
    private function __construct($tag, $description, \DateTime $start, \DateTime $end, $resolution, array $stats)
58
    {
59
        $this->tag = $tag;
60
        $this->description = $description;
61
        $this->resolution = $resolution;
62
        $this->start = $start;
63
        $this->end = $end;
64
        $this->stats = $stats;
65
    }
66
67
    /**
68
     * @param array $data
69
     *
70
     * @return StatisticsResponse
71
     */
72
    public static function create(array $data)
73
    {
74
        return new self(
75
            $data['tag'],
76
            $data['description'],
77
            new \DateTime($data['start']),
78
            new \DateTime($data['end']),
79
            $data['resolution'],
80
            $data['stats']
81
        );
82
    }
83
84
    /**
85
     * @return string
86
     */
87
    public function getTag()
88
    {
89
        return $this->tag;
90
    }
91
92
    /**
93
     * @return string
94
     */
95
    public function getDescription()
96
    {
97
        return $this->description;
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function getResolution()
104
    {
105
        return $this->resolution;
106
    }
107
108
    /**
109
     * @return \DateTime
110
     */
111
    public function getStart()
112
    {
113
        return $this->start;
114
    }
115
116
    /**
117
     * @return \DateTime
118
     */
119
    public function getEnd()
120
    {
121
        return $this->end;
122
    }
123
124
    /**
125
     * @return array
126
     */
127
    public function getStats()
128
    {
129
        return $this->stats;
130
    }
131
}
132