6
6
7
7
final class SendinblueEmailMessage
8
8
{
9
- protected array $ sender = [];
10
- protected array $ to = [];
11
- protected int $ templateId ;
12
- protected ?string $ subject = null ;
13
- protected ?array $ attachment = null ;
14
- protected ?array $ bcc = null ;
15
- protected ?array $ cc = null ;
16
- protected ?string $ htmlContent = null ;
17
- protected ?string $ textContent = null ;
18
- protected ?array $ replyTo = null ;
19
- protected ?array $ headers = null ;
20
- protected ?array $ params = null ;
21
-
22
- public function getSender (): array
23
- {
24
- return $ this ->sender ;
25
- }
26
-
27
- public function setSender (array $ sender ): SendinblueEmailMessage
28
- {
29
- $ this ->sender = $ sender ;
9
+ public array $ from = [];
10
+ public array $ to = [];
11
+ public array $ attachment = [];
12
+ public array $ bcc = [];
13
+ public array $ cc = [];
14
+ public int $ templateId ;
15
+ public ?string $ subject = null ;
16
+ public ?string $ htmlContent = null ;
17
+ public ?string $ textContent = null ;
18
+ public ?array $ replyTo = null ;
19
+ public ?array $ headers = null ;
20
+ public ?array $ params = null ;
21
+
22
+ public function from (array $ from ): SendinblueEmailMessage
23
+ {
24
+ $ this ->from = $ from ;
30
25
31
26
return $ this ;
32
27
}
33
28
34
- public function getTo (): array
35
- {
36
- return $ this ->to ;
37
- }
38
-
39
- public function setTo (array $ to ): SendinblueEmailMessage
29
+ public function to ($ name , $ email = null ): SendinblueEmailMessage
40
30
{
41
- $ this ->to [] = $ to ;
31
+ if (is_array ($ name )) {
32
+ $ this ->to = $ name ;
33
+ } else {
34
+ $ this ->to [] = [
35
+ 'name ' => $ name ,
36
+ 'email ' => $ email ,
37
+ ];
38
+ }
42
39
43
40
return $ this ;
44
41
}
45
42
46
- public function getBcc (): array
47
- {
48
- return $ this ->bcc ;
49
- }
50
-
51
- public function setBcc (array $ bcc ): SendinblueEmailMessage
43
+ public function bcc ($ name , $ email = null ): SendinblueEmailMessage
52
44
{
53
- $ this ->bcc = $ bcc ;
45
+ if (is_array ($ name )) {
46
+ $ this ->bcc = $ name ;
47
+ } else {
48
+ $ this ->bcc [] = [
49
+ 'name ' => $ name ,
50
+ 'email ' => $ email ,
51
+ ];
52
+ }
54
53
55
54
return $ this ;
56
55
}
57
56
58
- public function getCc ( ): array
57
+ public function cc ( $ name , $ email = null ): SendinblueEmailMessage
59
58
{
60
- return $ this ->cc ;
61
- }
62
-
63
- public function setCc (array $ cc ): SendinblueEmailMessage
64
- {
65
- $ this ->cc = $ cc ;
59
+ if (is_array ($ name )) {
60
+ $ this ->cc = $ name ;
61
+ } else {
62
+ $ this ->cc [] = [
63
+ 'name ' => $ name ,
64
+ 'email ' => $ email ,
65
+ ];
66
+ }
66
67
67
68
return $ this ;
68
69
}
69
70
70
- public function getSubject ( ): string
71
+ public function attachment ( $ name , $ content = null ): SendinblueEmailMessage
71
72
{
72
- return $ this ->subject ;
73
- }
74
-
75
- public function setSubject (string $ subject ): SendinblueEmailMessage
76
- {
77
- $ this ->subject = $ subject ;
73
+ if (is_array ($ name )) {
74
+ $ this ->attachment = $ name ;
75
+ } else {
76
+ $ this ->attachment [] = [
77
+ 'name ' => $ name ,
78
+ 'content ' => $ content ,
79
+ ];
80
+ }
78
81
79
82
return $ this ;
80
83
}
81
84
82
- public function getReplyTo ( ): array
85
+ public function subject ( string $ subject ): SendinblueEmailMessage
83
86
{
84
- return $ this ->replyTo ;
85
- }
86
-
87
- public function setReplyTo (array $ replyTo ): SendinblueEmailMessage
88
- {
89
- $ this ->replyTo = $ replyTo ;
87
+ $ this ->subject = $ subject ;
90
88
91
89
return $ this ;
92
90
}
93
91
94
- public function getAttachment (): array
95
- {
96
- return $ this ->attachment ;
97
- }
98
-
99
- public function setAttachment (array $ attachment ): SendinblueEmailMessage
92
+ public function replyTo (array $ replyTo ): SendinblueEmailMessage
100
93
{
101
- $ this ->attachment [] = $ attachment ;
94
+ $ this ->replyTo = $ replyTo ;
102
95
103
96
return $ this ;
104
97
}
105
98
106
- public function getHeaders (): array
107
- {
108
- return $ this ->headers ;
109
- }
110
-
111
- public function setHeaders (array $ headers ): SendinblueEmailMessage
99
+ public function headers (array $ headers ): SendinblueEmailMessage
112
100
{
113
101
$ this ->headers = $ headers ;
114
102
115
103
return $ this ;
116
104
}
117
105
118
- public function getTemplateId (): int
119
- {
120
- return $ this ->templateId ;
121
- }
122
-
123
- public function setTemplateId (int $ templateId ): SendinblueEmailMessage
106
+ public function templateId (int $ templateId ): SendinblueEmailMessage
124
107
{
125
108
$ this ->templateId = $ templateId ;
126
109
127
110
return $ this ;
128
111
}
129
112
130
- public function getHtmlContent (): string
131
- {
132
- return $ this ->htmlContent ;
133
- }
134
-
135
- public function setHtmlContent (string $ htmlContent ): SendinblueEmailMessage
113
+ public function htmlContent (string $ htmlContent ): SendinblueEmailMessage
136
114
{
137
115
$ this ->htmlContent = $ htmlContent ;
138
116
139
117
return $ this ;
140
118
}
141
119
142
- public function getTextContent (): string
143
- {
144
- return $ this ->textContent ;
145
- }
146
-
147
- public function setTextContent (string $ textContent ): SendinblueEmailMessage
120
+ public function textContent (string $ textContent ): SendinblueEmailMessage
148
121
{
149
122
$ this ->textContent = $ textContent ;
150
123
151
124
return $ this ;
152
125
}
153
126
154
- public function getParams (): array
155
- {
156
- return $ this ->params ;
157
- }
158
-
159
- public function setParams (array $ params ): SendinblueEmailMessage
127
+ public function params (array $ params ): SendinblueEmailMessage
160
128
{
161
129
$ this ->params = $ params ;
162
130
@@ -166,7 +134,7 @@ public function setParams(array $params): SendinblueEmailMessage
166
134
public function toArray (): array
167
135
{
168
136
$ data = [
169
- 'sender ' => $ this ->sender ,
137
+ 'sender ' => $ this ->from ,
170
138
'to ' => $ this ->to ,
171
139
'templateId ' => $ this ->templateId ,
172
140
'headers ' => $ this ->headers ,
0 commit comments