Conditions | 5 |
Paths | 16 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
32 | public function buildMailMessage(array $option) |
||
33 | { |
||
34 | // Set defaults |
||
35 | if (!array_key_exists('from', $option)) { |
||
36 | $option['from'] = ['[email protected]' => 'FromTester']; |
||
37 | } |
||
38 | |||
39 | if (!array_key_exists('to', $option)) { |
||
40 | $option['to'] = ['[email protected]' => 'ToTester']; |
||
41 | } |
||
42 | |||
43 | if (!array_key_exists('subject', $option)) { |
||
44 | $option['subject'] = 'Testing Email'; |
||
45 | } |
||
46 | // Make sure Body exists |
||
47 | if (!array_key_exists('body', $option)) { |
||
48 | throw new RuntimeException('You really need to set the body'); |
||
49 | } |
||
50 | |||
51 | $this->emailMessage = Swift_Message::newInstance() |
||
52 | ->setSubject($option['subject']) |
||
53 | ->setFrom($option['from']) |
||
54 | ->setTo($option['to']) |
||
55 | ->setBody($option['body']); |
||
56 | return $this; |
||
57 | } |
||
58 | } |
||
59 |