Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
|
100.00% |
13 / 13 |
CRAP | |
100.00% |
1 / 1 |
| AbstractMailClient | |
100.00% |
22 / 22 |
|
100.00% |
13 / 13 |
14 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
2 | |||
| getHost | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPort | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getService | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUsername | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getPassword | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getFolder | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setHost | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setPort | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setService | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setUsername | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setPassword | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| setFolder | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Mail\Client; |
| 15 | |
| 16 | /** |
| 17 | * Abstract mail client class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\Mail |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 4.0.7 |
| 25 | */ |
| 26 | abstract class AbstractMailClient implements MailClientInterface |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Mail client host |
| 31 | * @var ?string |
| 32 | */ |
| 33 | protected ?string $host = null; |
| 34 | |
| 35 | /** |
| 36 | * Mail client port |
| 37 | * @var int|string|null |
| 38 | */ |
| 39 | protected int|string|null $port = null; |
| 40 | |
| 41 | /** |
| 42 | * Mail client service (pop, imap, nntp, etc.) |
| 43 | * @var ?string |
| 44 | */ |
| 45 | protected ?string $service = null; |
| 46 | |
| 47 | /** |
| 48 | * Username |
| 49 | * @var string |
| 50 | */ |
| 51 | protected string $username = ''; |
| 52 | |
| 53 | /** |
| 54 | * Password |
| 55 | * @var string |
| 56 | */ |
| 57 | protected string $password = ''; |
| 58 | |
| 59 | /** |
| 60 | * Current folder |
| 61 | * @var string |
| 62 | */ |
| 63 | protected string $folder = ''; |
| 64 | |
| 65 | /** |
| 66 | * Constructor |
| 67 | * |
| 68 | * Instantiate the mail client object |
| 69 | * |
| 70 | * @param string $host |
| 71 | * @param int|string $port |
| 72 | * @param ?string $service |
| 73 | */ |
| 74 | public function __construct(string $host, int|string $port, ?string $service = null) |
| 75 | { |
| 76 | $this->setHost($host); |
| 77 | $this->setPort($port); |
| 78 | if ($service !== null) { |
| 79 | $this->setService($service); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Get mail client host |
| 85 | * |
| 86 | * @return ?string |
| 87 | */ |
| 88 | public function getHost(): ?string |
| 89 | { |
| 90 | return $this->host; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get mail client port |
| 95 | * |
| 96 | * @return int|string|null |
| 97 | */ |
| 98 | public function getPort(): int|string|null |
| 99 | { |
| 100 | return $this->port; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Get mail client service |
| 105 | * |
| 106 | * @return ?string |
| 107 | */ |
| 108 | public function getService(): ?string |
| 109 | { |
| 110 | return $this->service; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Get username |
| 115 | * |
| 116 | * @return string |
| 117 | */ |
| 118 | public function getUsername(): string |
| 119 | { |
| 120 | return $this->username; |
| 121 | } |
| 122 | |
| 123 | /** |
| 124 | * Get password |
| 125 | * |
| 126 | * @return string |
| 127 | */ |
| 128 | public function getPassword(): string |
| 129 | { |
| 130 | return $this->password; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Get folder |
| 135 | * |
| 136 | * @return string |
| 137 | */ |
| 138 | public function getFolder(): string |
| 139 | { |
| 140 | return $this->folder; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Set mail client host |
| 145 | * |
| 146 | * @param string $host |
| 147 | * @return AbstractMailClient |
| 148 | */ |
| 149 | public function setHost(string $host): AbstractMailClient |
| 150 | { |
| 151 | $this->host = $host; |
| 152 | return $this; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Set mail client port |
| 157 | * |
| 158 | * @param int|string $port |
| 159 | * @return AbstractMailClient |
| 160 | */ |
| 161 | public function setPort(int|string$port): AbstractMailClient |
| 162 | { |
| 163 | $this->port = $port; |
| 164 | return $this; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * Set mail client service |
| 169 | * |
| 170 | * @param string $service |
| 171 | * @return AbstractMailClient |
| 172 | */ |
| 173 | public function setService(string $service): AbstractMailClient |
| 174 | { |
| 175 | $this->service = $service; |
| 176 | return $this; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Set username |
| 181 | * |
| 182 | * @param string $username |
| 183 | * @return AbstractMailClient |
| 184 | */ |
| 185 | public function setUsername(string $username): AbstractMailClient |
| 186 | { |
| 187 | $this->username = $username; |
| 188 | return $this; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Set password |
| 193 | * |
| 194 | * @param string $password |
| 195 | * @return AbstractMailClient |
| 196 | */ |
| 197 | public function setPassword(string $password): AbstractMailClient |
| 198 | { |
| 199 | $this->password = $password; |
| 200 | return $this; |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Set folder |
| 205 | * |
| 206 | * @param string $folder |
| 207 | * @return AbstractMailClient |
| 208 | */ |
| 209 | public function setFolder(string $folder): AbstractMailClient |
| 210 | { |
| 211 | $this->folder = $folder; |
| 212 | return $this; |
| 213 | } |
| 214 | |
| 215 | } |