96% of 124OPs |
100% of 22Lines |
74% of 19Branches |
100% of 7Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\mailers\mail::send() | 124 | 96% | 22 | 100% | 19 | 74% | 7 | 100% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\mailers; |
4 |
|
5 |
use |
6 |
mageekguy\atoum, |
7 |
mageekguy\atoum\exceptions |
8 |
; |
9 |
|
10 |
class mail extends atoum\mailer |
11 |
{ |
12 |
const eol = "\r\n"; |
13 |
|
14 |
public function send($something)100% |
15 |
{ |
16 |
if ($this->to === null) |
17 |
{ |
18 |
throw new exceptions\runtime('To is undefined'); |
19 |
} |
20 |
|
21 |
if ($this->subject === null) |
22 |
{ |
23 |
throw new exceptions\runtime('Subject is undefined'); |
24 |
} |
25 |
|
26 |
if ($this->from === null) |
27 |
{ |
28 |
throw new exceptions\runtime('From is undefined'); |
29 |
} |
30 |
|
31 |
if ($this->replyTo === null) |
32 |
{ |
33 |
throw new exceptions\runtime('Reply to is undefined'); |
34 |
} |
35 |
|
36 |
if ($this->xMailer === null) |
37 |
{ |
38 |
throw new exceptions\runtime('X-mailer is undefined'); |
39 |
} |
40 |
|
41 |
$headers = 'From: ' . $this->from . self::eol . 'Reply-To: ' . $this->replyTo . self::eol . 'X-Mailer: ' . $this->xMailer; |
42 |
|
43 |
if ($this->contentType !== null) |
44 |
{ |
45 |
$headers .= self::eol . 'Content-Type: ' . $this->contentType[0] . '; charset="' . $this->contentType[1] . '"'; |
46 |
} |
47 |
|
48 |
$this->adapter->mail($this->to, $this->subject, (string) $something, $headers); |
49 |
|
50 |
return $this; |
51 |
} |
52 |
} |