11<?php
22namespace SparkPost \SendGridCompatibility ;
33
4- class Email {
4+ class Email
5+ {
56 public $ model ;
67
7-
88 /**
9- * @desc Sets up the model for saving the configuration
9+ * Sets up the model for saving the configuration
1010 */
11- public function __construct () {
11+ public function __construct ()
12+ {
1213 $ this ->model = array ();
1314 }
1415
1516 /**
16- * @desc adds addresses as recipients
17+ * Adds addresses as recipients
18+ *
1719 * @param string $address
1820 * @param string $name optional
1921 * @return \SparkPost\SendGridCompatibility\Email
2022 */
21- public function addTo ($ address , $ name = null ) {
23+ public function addTo ($ address , $ name = null )
24+ {
2225 if (!isset ($ this ->model ['recipients ' ])) {
2326 $ this ->model ['recipients ' ] = array ();
2427 }
2528
26- if (isset ($ name )) {
27- $ address = array ('address ' => array ('email ' => $ address , 'name ' => $ name ));
29+ if (isset ($ name )) {
30+ $ address = array ('address ' => array ('email ' => $ address , 'name ' => $ name ));
2831 } else {
29- $ address = array ('address ' => array ('email ' => $ address ));
32+ $ address = array ('address ' => array ('email ' => $ address ));
3033 }
3134
3235 array_push ($ this ->model ['recipients ' ], $ address );
36+
3337 return $ this ;
3438 }
3539
3640 /**
37- * @desc explicitly sets a list of addresses
38- * @param array $addresses
39- * @return \SparkPost\SendGridCompatibility\Email
40- */
41- public function setTos (array $ addresses ) {
41+ * Explicitly sets a list of addresses
42+ *
43+ * @param array $addresses
44+ * @return \SparkPost\SendGridCompatibility\Email
45+ */
46+ public function setTos (array $ addresses )
47+ {
4248 $ this ->model ['recipients ' ] = $ addresses ;
49+
4350 return $ this ;
4451 }
4552
4653 /**
47- * @desc sets the from address
54+ * Sets the from address
55+ *
4856 * @param string $address
49- * @return \MessageSystems\SendGridCompatibility\Email
57+ * @return $this
5058 */
51- public function setFrom ($ address ) {
59+ public function setFrom ($ address )
60+ {
5261 $ this ->model ['from ' ] = array ('email ' => $ address );
62+
5363 return $ this ;
5464 }
5565
5666 /**
57- * @desc sets the name for the from address
67+ * Sets the name for the from address
68+ *
5869 * @param string $name
70+ * @return $this
71+ * @throws \Exception
5972 */
60- public function setFromName ($ name ) {
61- if (!isset ($ this ->model ['from ' ])){
73+ public function setFromName ($ name )
74+ {
75+ if (!isset ($ this ->model ['from ' ])) {
6276 throw new \Exception ('Must set \'From \' prior to setting \'From Name \'. ' );
6377 }
6478 $ this ->model ['from ' ]['name ' ] = $ name ;
79+
6580 return $ this ;
6681 }
6782
6883 /**
69- * @desc sets the reply to field
84+ * Sets the reply to field
85+ *
7086 * @param string $address
71- * @return \MessageSystems\SendGridCompatibility\Email
87+ * @return $this
7288 */
73- public function setReplyTo ($ address ) {
89+ public function setReplyTo ($ address )
90+ {
7491 $ this ->model ['replyTo ' ] = $ address ;
92+
7593 return $ this ;
7694 }
7795
7896 /**
79- * @desc throws an error because bcc fields are not yet implemented.
97+ * Throws an error because bcc fields are not yet implemented
98+ *
8099 * @throws \Exception
81100 * @param string $address
82- * @return \MessageSystems\SendGridCompatibility\Email
101+ * @return $this
83102 */
84- public function addBcc ($ address ) {
103+ public function addBcc ($ address )
104+ {
85105 throw new \Exception ('Adding bcc recipients is not yet supported, try adding them as a \'to \' address ' );
86106 }
87107
88108 /**
89- * @desc sets the subject header
109+ * Sets the subject header
110+ *
90111 * @param string $subject
91112 * @return \SparkPost\SendGridCompatibility\Email
92113 */
93- public function setSubject ($ subject ) {
114+ public function setSubject ($ subject )
115+ {
94116 $ this ->model ['subject ' ] = $ subject ;
117+
95118 return $ this ;
96119 }
97120
98121 /**
99- * @desc sets the text body
122+ * Sets the text body
123+ *
100124 * @param string $text
101125 * @return \SparkPost\SendGridCompatibility\Email
102126 */
103- public function setText ($ text ) {
127+ public function setText ($ text )
128+ {
104129 $ this ->model ['text ' ] = $ text ;
130+
105131 return $ this ;
106132 }
107133
108134 /**
109- * @desc sets the html body
135+ * Sets the html body
136+ *
110137 * @param string $html
111138 * @return \SparkPost\SendGridCompatibility\Email
112139 */
113- public function setHtml ($ html ) {
140+ public function setHtml ($ html )
141+ {
114142 $ this ->model ['html ' ] = $ html ;
143+
115144 return $ this ;
116145 }
117146
118147 /**
119- * @desc Throws an exception since adding categories is not yet supported
148+ * Throws an exception since adding categories is not yet supported
149+ *
120150 * @throws \Exception
121151 * @param string $category
122152 * @throws \Exception
123153 */
124- public function addCategory ($ category ) {
154+ public function addCategory ($ category )
155+ {
125156 throw new \Exception ('Adding categories is not yet supported ' );
126157 }
127158
128159 /**
129- * @desc Throws an exception since adding attachments is not yet supported
130- * @throws Exception
160+ * Throws an exception since adding attachments is not yet supported
161+ *
131162 * @param mixed $attachment
163+ * @throws \Exception
132164 */
133- public function addAttachment ($ attachment ) {
165+ public function addAttachment ($ attachment )
166+ {
134167 throw new \Exception ('Adding attachments is not yet supported ' );
135168 }
136169
137170 /**
138- * @desc Adds transmission level substitution data
171+ * Adds transmission level substitution data
172+ *
139173 * @param string $name
140174 * @param mixed $values
141175 * @return \SparkPost\SendGridCompatibility\Email
142176 */
143- public function addSubstitution ($ name , $ values ) {
177+ public function addSubstitution ($ name , $ values )
178+ {
144179 if (!isset ($ this ->model ['substitutionData ' ])) {
145180 $ this ->model ['substitutionData ' ] = array ();
146181 }
@@ -150,50 +185,62 @@ public function addSubstitution($name, $values) {
150185 }
151186
152187 /**
153- * @desc Adds transmission level substitution data
188+ * Adds transmission level substitution data
189+ *
154190 * @param string $name
155191 * @param mixed $values
156192 */
157- public function addSection ($ name , $ values ) {
193+ public function addSection ($ name , $ values )
194+ {
158195 $ this ->addSubstitution ($ name , $ values );
159196 }
160197
161198 /**
162- * @desc Throws an exception because arguments for third party systems is not supported
163- * @throws Exception
199+ * Throws an exception because arguments for third party systems is not supported
200+ *
201+ * @param $key
164202 * @param mixed $value
203+ * @throws \Exception
165204 */
166- public function addUniqueArg ($ key , $ value ) {
205+ public function addUniqueArg ($ key , $ value )
206+ {
167207 throw new \Exception ('Adding Unique Arguments is not yet supported ' );
168208 }
169209
170210 /**
171- * @desc Throws an exception because arguments for third party systems is not supported
172- * @throws Exception
211+ * Throws an exception because arguments for third party systems is not supported
212+ *
173213 * @param mixed $values
214+ * @throws \Exception
174215 */
175- public function setUniqueArgs (array $ values ) {
216+ public function setUniqueArgs (array $ values )
217+ {
176218 throw new \Exception ('Setting Unique Arguments is not yet supported ' );
177219 }
178220
179221 /**
180- * @desc Adds custom headers to the email header
222+ * Adds custom headers to the email header
223+ *
181224 * @param string $name
182225 * @param string $value
183226 */
184- public function addHeader ($ name , $ value ) {
227+ public function addHeader ($ name , $ value )
228+ {
185229 if (!isset ($ this ->model ['customHeaders ' ])) {
186230 $ this ->model ['customHeaders ' ] = array ();
187231 }
188232 $ this ->model ['customHeaders ' ][$ name ] = $ value ;
189233 }
190234
191235 /**
192- * @desc converts this object to a configuration for a SparkPost transmission
236+ * Converts this object to a configuration for a SparkPost transmission
237+ *
193238 * @return array
194239 */
195- public function toSparkPostTransmission () {
240+ public function toSparkPostTransmission ()
241+ {
196242 return $ this ->model ;
197243 }
198244}
245+
199246?>
0 commit comments