|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Mailer.php |
| 4 | + * |
| 5 | + * This file is part of InitPHP. |
| 6 | + * |
| 7 | + * @author Muhammet ŞAFAK <info@muhammetsafak.com.tr> |
| 8 | + * @copyright Copyright © 2022 InitPHP |
| 9 | + * @license http://initphp.github.io/license.txt MIT |
| 10 | + * @version 1.1 |
| 11 | + * @link https://www.muhammetsafak.com.tr |
| 12 | + */ |
| 13 | + |
| 14 | +declare(strict_types=1); |
| 15 | + |
| 16 | +namespace InitPHP\Mailer\Facade; |
| 17 | + |
| 18 | +use \InitPHP\Mailer\Mailer as MailerInstance; |
| 19 | + |
| 20 | +/** |
| 21 | + * @mixin MailerInstance |
| 22 | + * @method static MailerInstance clear(bool $clearAttachments = false) |
| 23 | + * @method static MailerInstance setHeader(string $header, string $value) |
| 24 | + * @method static MailerInstance setFrom(string $from, string $name = '', null|string $returnPath = null) |
| 25 | + * @method static MailerInstance setReplyTo(string $replyTo, string $name = '') |
| 26 | + * @method static MailerInstance setTo(string[]|string $to) |
| 27 | + * @method static MailerInstance setCC(string $cc) |
| 28 | + * @method static MailerInstance setBCC(string $bcc, null|int $limit = null) |
| 29 | + * @method static MailerInstance setSubject(string $subject) |
| 30 | + * @method static MailerInstance setMessage(string $body) |
| 31 | + * @method static MailerInstance setAttachmentCID(string $fileName) |
| 32 | + * @method static MailerInstance setAltMessage(string $str) |
| 33 | + * @method static MailerInstance setMailType(string $type = 'text') |
| 34 | + * @method static MailerInstance setWordWrap(bool $wordWrap = true) |
| 35 | + * @method static MailerInstance setProtocol(string $protocol = 'mail') |
| 36 | + * @method static MailerInstance setPriority(int $n = 3) |
| 37 | + * @method static MailerInstance setNewline(string $newLine = PHP_EOL) |
| 38 | + * @method static MailerInstance setCRLF(string $CRLF = PHP_EOL) |
| 39 | + * @method static MailerInstance|false attach(string $file, string $disposition = '', null|string $newName = null, null|string $mime = null) |
| 40 | + * @method static string getMessageID() |
| 41 | + * @method static bool validateEmail(string[] $mails) |
| 42 | + * @method static bool isValidEmail(string $mail) |
| 43 | + * @method static string|string[] cleanEmail(string|string[] $mail) |
| 44 | + * @method static string wordWrap(string $str, null|int $chars = null) |
| 45 | + * @method static bool send(bool $autoClear = true) |
| 46 | + * @method static void batchBCCSend() |
| 47 | + * @method static string printDebugger(array $include = ['headers', 'subject', 'body']) |
| 48 | + */ |
| 49 | +class Mailer |
| 50 | +{ |
| 51 | + |
| 52 | + protected static MailerInstance $instance; |
| 53 | + |
| 54 | + public function __call($name, $arguments) |
| 55 | + { |
| 56 | + return self::__getInstance()->{$name}(...$arguments); |
| 57 | + } |
| 58 | + |
| 59 | + public static function __callStatic($name, $arguments) |
| 60 | + { |
| 61 | + return self::__getInstance()->{$name}(...$arguments); |
| 62 | + } |
| 63 | + |
| 64 | + protected static function __getInstance(): MailerInstance |
| 65 | + { |
| 66 | + if (!isset(self::$instance)) { |
| 67 | + self::$instance = MailerInstance::newInstance(); |
| 68 | + } |
| 69 | + |
| 70 | + return self::$instance; |
| 71 | + } |
| 72 | + |
| 73 | +} |
0 commit comments