|
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\Routes\Dto; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @author David Garcia <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
final class RouteDto |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
private $id; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var int |
|
24
|
|
|
*/ |
|
25
|
|
|
private $priority; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
private $filter; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @var ActionDto[] |
|
34
|
|
|
*/ |
|
35
|
|
|
private $actions; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $description; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var \DateTime |
|
44
|
|
|
*/ |
|
45
|
|
|
private $createdAt; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* RouteDto Named Constructor. |
|
49
|
|
|
* |
|
50
|
|
|
* @param array $data |
|
51
|
|
|
* |
|
52
|
|
|
* @return RouteDto |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function create(array $data) |
|
55
|
|
|
{ |
|
56
|
|
|
return new self( |
|
57
|
|
|
isset($data['id']) ? $data['id'] : null, |
|
58
|
|
|
isset($data['priority']) ? $data['priority'] : null, |
|
59
|
|
|
isset($data['expression']) ? $data['expression'] : null, |
|
60
|
|
|
isset($data['actions']) ? $data['actions'] : [], |
|
61
|
|
|
isset($data['description']) ? $data['description'] : null, |
|
62
|
|
|
isset($data['created_at']) ? $data['created_at'] : null |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* RouteDto Private Constructor. |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $id |
|
70
|
|
|
* @param int $priority |
|
71
|
|
|
* @param string $expression |
|
72
|
|
|
* @param array $actions |
|
73
|
|
|
* @param string $description |
|
74
|
|
|
* @param string $createdAt |
|
75
|
|
|
*/ |
|
76
|
|
|
private function __construct($id, $priority, $expression, $actions, $description, $createdAt) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->id = $id; |
|
79
|
|
|
$this->priority = $priority; |
|
80
|
|
|
$this->filter = $expression; |
|
81
|
|
|
$this->actions = ActionDto::createMultiple($actions); |
|
82
|
|
|
$this->description = $description; |
|
83
|
|
|
$this->createdAt = !is_null($createdAt) ? new \DateTime($createdAt) : $createdAt; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return mixed |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getId() |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->id; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return mixed |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getActions() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->actions; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @return mixed |
|
104
|
|
|
*/ |
|
105
|
|
|
public function getDescription() |
|
106
|
|
|
{ |
|
107
|
|
|
return $this->description; |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return mixed |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getFilter() |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->filter; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* @return mixed |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getPriority() |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->priority; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return mixed |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getCreatedAt() |
|
130
|
|
|
{ |
|
131
|
|
|
return $this->createdAt; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|