chore: Аннотации к типам
This commit is contained in:
parent
09a61244ca
commit
1e27648a12
17 changed files with 217 additions and 81 deletions
46
src/Mail.php
46
src/Mail.php
|
|
@ -12,17 +12,27 @@ use ctiso\Path,
|
|||
|
||||
class Mail
|
||||
{
|
||||
/** @var string */
|
||||
public $_from;
|
||||
/** @var string */
|
||||
public $_to;
|
||||
/** @var string */
|
||||
public $_subject;
|
||||
/** @var string */
|
||||
public $content;
|
||||
/** @var string */
|
||||
public $copy;
|
||||
|
||||
/** @var string */
|
||||
private $encoding;
|
||||
/** @var string */
|
||||
private $_notify = null;
|
||||
|
||||
/** @var array */
|
||||
protected $attachment = array();
|
||||
/** @var string */
|
||||
protected $uniqid;
|
||||
/** @var string */
|
||||
protected $type = "text/plain";
|
||||
|
||||
function __construct()
|
||||
|
|
@ -34,7 +44,7 @@ class Mail
|
|||
/**
|
||||
* Установка отправителя
|
||||
*/
|
||||
function from(string $name)
|
||||
function from(string $name): void
|
||||
{
|
||||
// filter_var($name, FILTER_VALIDATE_EMAIL);
|
||||
$this->_from = $name;
|
||||
|
|
@ -43,23 +53,23 @@ class Mail
|
|||
/**
|
||||
* Установка получателя
|
||||
*/
|
||||
function to(string $name) // recipient
|
||||
function to(string $name): void // recipient
|
||||
{
|
||||
$this->_to = $name;
|
||||
}
|
||||
|
||||
function replyTo($name) // recipient
|
||||
function replyTo($name): void // recipient
|
||||
{}
|
||||
|
||||
/**
|
||||
* Установка получателей копии
|
||||
*/
|
||||
function copy(string $name) // recipient cc
|
||||
function copy(string $name): void // recipient cc
|
||||
{
|
||||
$this->copy = $name;
|
||||
}
|
||||
|
||||
function notify(string $notify)
|
||||
function notify(string $notify): void
|
||||
{
|
||||
$this->_notify = $notify;
|
||||
}
|
||||
|
|
@ -67,7 +77,7 @@ class Mail
|
|||
/**
|
||||
* Тема письма
|
||||
*/
|
||||
function subject(string $subject)
|
||||
function subject(string $subject): void
|
||||
{
|
||||
$this->_subject = $subject;
|
||||
}
|
||||
|
|
@ -75,7 +85,7 @@ class Mail
|
|||
/**
|
||||
* Текст письма
|
||||
*/
|
||||
function setContent(string $text)
|
||||
function setContent(string $text): void
|
||||
{
|
||||
$this->content = $text;
|
||||
}
|
||||
|
|
@ -83,7 +93,7 @@ class Mail
|
|||
/**
|
||||
* Кодировка текста в письме
|
||||
*/
|
||||
function setEncoding(string $encoding)
|
||||
function setEncoding(string $encoding): void
|
||||
{
|
||||
$this->encoding = $encoding;
|
||||
}
|
||||
|
|
@ -91,7 +101,7 @@ class Mail
|
|||
/**
|
||||
* Добавление вложения из файла
|
||||
*/
|
||||
function addAttachment(string $filename, $name = false)
|
||||
function addAttachment(string $filename, $name = false): void
|
||||
{
|
||||
if (file_exists($filename)) { // assert ??
|
||||
$file = fopen($filename, "rb");
|
||||
|
|
@ -102,7 +112,7 @@ class Mail
|
|||
}
|
||||
}
|
||||
|
||||
function setType($type)
|
||||
function setType($type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
|
@ -110,12 +120,16 @@ class Mail
|
|||
/**
|
||||
* Добавление вложения из строки с указанием имени файла
|
||||
*/
|
||||
function addAttachmentRaw($data, string $name)
|
||||
function addAttachmentRaw($data, string $name): void
|
||||
{
|
||||
$this->attachment[] = [$data, $name];
|
||||
}
|
||||
|
||||
function quote($var, $val)
|
||||
/**
|
||||
* @param string $var
|
||||
* @param string $val
|
||||
*/
|
||||
function quote($var, $val): string
|
||||
{
|
||||
return ";" . PHP_EOL . "\t" . $var . "=\"" . $val . "\"";
|
||||
}
|
||||
|
|
@ -123,8 +137,12 @@ class Mail
|
|||
/**
|
||||
* Общий формат тегов MIME
|
||||
* @see http://tools.ietf.org/html/rfc2045
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $args
|
||||
*/
|
||||
function mimeTag($name, $value, array $args = [])
|
||||
function mimeTag($name, $value, array $args = []): string
|
||||
{
|
||||
assert(is_string($name));
|
||||
assert(is_string($value));
|
||||
|
|
@ -136,7 +154,7 @@ class Mail
|
|||
*
|
||||
* @see http://tools.ietf.org/html/rfc2047
|
||||
*/
|
||||
function encodedWord(string $text, string $encoding = 'B')
|
||||
function encodedWord(string $text, string $encoding = 'B'): string
|
||||
{
|
||||
return "=?{$this->encoding}?$encoding?" . base64_encode($text) . "?=";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue