100% of 174OPs |
100% of 39Lines |
97% of 30Branches |
95% of 20Paths |
| # | |
|---|---|
| 1 |
<?php |
| 2 | |
| 3 |
namespace mageekguy\atoum; |
| 4 | |
| 5 |
use |
| 6 |
mageekguy\atoum, |
| 7 |
mageekguy\atoum\exceptions |
| 8 |
; |
| 9 | |
| 10 |
abstract class mailer |
| 11 |
{
|
| 12 |
protected $to = null; |
| 13 |
protected $from = null; |
| 14 |
protected $xMailer = null; |
| 15 |
protected $replyTo = null; |
| 16 |
protected $subject = null; |
| 17 |
protected $contentType = null; |
| 18 |
protected $adapter = null; |
| 19 | |
| 20 |
public function __construct(atoum\adapter $adapter = null)100% |
| 21 |
{
|
| 22 |
$this->setAdapter($adapter ?: new atoum\adapter()); |
| 23 |
} |
| 24 | |
| 25 |
public function setAdapter(atoum\adapter $adapter)100% |
| 26 |
{
|
| 27 |
$this->adapter = $adapter; |
| 28 | |
| 29 |
return $this; |
| 30 |
} |
| 31 | |
| 32 |
public function getAdapter()100% |
| 33 |
{
|
| 34 |
return $this->adapter; |
| 35 |
} |
| 36 | |
| 37 |
public function addTo($to, $realName = null)100% |
| 38 |
{
|
| 39 |
if ($this->to !== null) |
| 40 |
{
|
| 41 |
$this->to .= ','; |
| 42 |
} |
| 43 | |
| 44 |
if ($realName === null) |
| 45 |
{
|
| 46 |
$this->to .= $to; |
| 47 |
} |
| 48 |
else |
| 49 |
{
|
| 50 |
$this->to .= $realName . ' <' . $to . '>'; |
| 51 |
} |
| 52 | |
| 53 |
return $this; |
| 54 |
} |
| 55 | |
| 56 |
public function getTo()100% |
| 57 |
{
|
| 58 |
return $this->to; |
| 59 |
} |
| 60 | |
| 61 |
public function setSubject($subject)100% |
| 62 |
{
|
| 63 |
$this->subject = (string) $subject; |
| 64 | |
| 65 |
return $this; |
| 66 |
} |
| 67 | |
| 68 |
public function getSubject()100% |
| 69 |
{
|
| 70 |
return $this->subject; |
| 71 |
} |
| 72 | |
| 73 |
public function setFrom($from, $realName = null)100% |
| 74 |
{
|
| 75 |
if ($realName === null) |
| 76 |
{
|
| 77 |
$this->from = (string) $from; |
| 78 |
} |
| 79 |
else |
| 80 |
{
|
| 81 |
$this->from = $realName . ' <' . $from . '>'; |
| 82 |
} |
| 83 | |
| 84 |
return $this; |
| 85 |
} |
| 86 | |
| 87 |
public function getFrom()100% |
| 88 |
{
|
| 89 |
return $this->from; |
| 90 |
} |
| 91 | |
| 92 |
public function setReplyTo($replyTo, $realName = null)100% |
| 93 |
{
|
| 94 |
if ($realName === null) |
| 95 |
{
|
| 96 |
$this->replyTo = (string) $replyTo; |
| 97 |
} |
| 98 |
else |
| 99 |
{
|
| 100 |
$this->replyTo = $realName . ' <' . $replyTo . '>'; |
| 101 |
} |
| 102 | |
| 103 |
return $this; |
| 104 |
} |
| 105 | |
| 106 |
public function getReplyTo()100% |
| 107 |
{
|
| 108 |
return $this->replyTo; |
| 109 |
} |
| 110 | |
| 111 |
public function setXMailer($mailer)100% |
| 112 |
{
|
| 113 |
$this->xMailer = (string) $mailer; |
| 114 | |
| 115 |
return $this; |
| 116 |
} |
| 117 | |
| 118 |
public function getXMailer()100% |
| 119 |
{
|
| 120 |
return $this->xMailer; |
| 121 |
} |
| 122 | |
| 123 |
public function setContentType($type = 'text/plain', $charset = 'utf-8')100% |
| 124 |
{
|
| 125 |
$this->contentType = array($type, $charset); |
| 126 | |
| 127 |
return $this; |
| 128 |
} |
| 129 | |
| 130 |
public function getContentType()100% |
| 131 |
{
|
| 132 |
return $this->contentType; |
| 133 |
} |
| 134 | |
| 135 |
public abstract function send($something); |
| 136 |
} |