Code Duplication    Length = 15-15 lines in 6 locations

src/Options/BodyOptions.php 1 location

@@ 103-117 (lines=15) @@
100
     * @return $this
101
     * @throws \AcMailer\Exception\InvalidArgumentException
102
     */
103
    public function setTemplate($template)
104
    {
105
        if (is_array($template)) {
106
            $this->template = new TemplateOptions($template);
107
        } elseif ($template instanceof TemplateOptions) {
108
            $this->template = $template;
109
        } else {
110
            throw new InvalidArgumentException(sprintf(
111
                'Template should be an array or an AcMailer\Options\TemplateOptions object. %s provided.',
112
                is_object($template) ? get_class($template) : gettype($template)
113
            ));
114
        }
115
116
        return $this;
117
    }
118
}
119

src/Options/MessageOptions.php 2 locations

@@ 217-231 (lines=15) @@
214
     * @param BodyOptions|array $body
215
     * @return $this
216
     */
217
    public function setBody($body)
218
    {
219
        if (is_array($body)) {
220
            $this->body = new BodyOptions($body);
221
        } elseif ($body instanceof BodyOptions) {
222
            $this->body = $body;
223
        } else {
224
            throw new InvalidArgumentException(sprintf(
225
                'Body should be an array or an AcMailer\\Options\\BodyOptions, %s provided',
226
                is_object($body) ? get_class($body) : gettype($body)
227
            ));
228
        }
229
230
        return $this;
231
    }
232
233
    /**
234
     * @return AttachmentsOptions
@@ 249-263 (lines=15) @@
246
     * @param AttachmentsOptions|array $attachments
247
     * @return $this
248
     */
249
    public function setAttachments($attachments)
250
    {
251
        if (is_array($attachments)) {
252
            $this->attachments = new AttachmentsOptions($attachments);
253
        } elseif ($attachments instanceof AttachmentsOptions) {
254
            $this->attachments = $attachments;
255
        } else {
256
            throw new InvalidArgumentException(sprintf(
257
                'Attachments should be an array or an AcMailer\\Options\\AttachmentsOptions, %s provided',
258
                is_object($attachments) ? get_class($attachments) : gettype($attachments)
259
            ));
260
        }
261
262
        return $this;
263
    }
264
}
265

src/Options/MailOptions.php 3 locations

@@ 120-134 (lines=15) @@
117
     * @return $this
118
     * @throws \AcMailer\Exception\InvalidArgumentException
119
     */
120
    public function setMessageOptions($messageOptions)
121
    {
122
        if (is_array($messageOptions)) {
123
            $this->messageOptions = new MessageOptions($messageOptions);
124
        } elseif ($messageOptions instanceof MessageOptions) {
125
            $this->messageOptions = $messageOptions;
126
        } else {
127
            throw new InvalidArgumentException(sprintf(
128
                'MessageOptions should be an array or an AcMailer\Options\MessageOptions object. %s provided.',
129
                is_object($messageOptions) ? get_class($messageOptions) : gettype($messageOptions)
130
            ));
131
        }
132
133
        return $this;
134
    }
135
136
    /**
137
     * @return SmtpOptions
@@ 152-166 (lines=15) @@
149
     * @param SmtpOptions|array $smtpOptions
150
     * @return $this
151
     */
152
    public function setSmtpOptions($smtpOptions)
153
    {
154
        if (is_array($smtpOptions)) {
155
            $this->smtpOptions = new SmtpOptions($smtpOptions);
156
        } elseif ($smtpOptions instanceof SmtpOptions) {
157
            $this->smtpOptions = $smtpOptions;
158
        } else {
159
            throw new InvalidArgumentException(sprintf(
160
                'SmtpOptions should be an array or an Zend\Mail\Transport\SmtpOptions object. %s provided.',
161
                is_object($smtpOptions) ? get_class($smtpOptions) : gettype($smtpOptions)
162
            ));
163
        }
164
165
        return $this;
166
    }
167
168
    /**
169
     * @return FileOptions
@@ 184-198 (lines=15) @@
181
     * @param FileOptions|array $fileOptions
182
     * @return $this
183
     */
184
    public function setFileOptions($fileOptions)
185
    {
186
        if (is_array($fileOptions)) {
187
            $this->fileOptions = new FileOptions($fileOptions);
188
        } elseif ($fileOptions instanceof FileOptions) {
189
            $this->fileOptions = $fileOptions;
190
        } else {
191
            throw new InvalidArgumentException(sprintf(
192
                'FileOptions should be an array or an Zend\Mail\Transport\FileOptions object. %s provided.',
193
                is_object($fileOptions) ? get_class($fileOptions) : gettype($fileOptions)
194
            ));
195
        }
196
197
        return $this;
198
    }
199
200
    /**
201
     * @return array