api/symfony/Component/Mime/Address.yaml

73 lines
4.1 KiB
YAML
Raw Permalink Normal View History

2024-09-26 09:03:21 +00:00
name: Address
class_comment: null
dependencies:
- name: EmailValidator
type: class
source: Egulias\EmailValidator\EmailValidator
- name: MessageIDValidation
type: class
source: Egulias\EmailValidator\Validation\MessageIDValidation
- name: RFCValidation
type: class
source: Egulias\EmailValidator\Validation\RFCValidation
- name: IdnAddressEncoder
type: class
source: Symfony\Component\Mime\Encoder\IdnAddressEncoder
- name: InvalidArgumentException
type: class
source: Symfony\Component\Mime\Exception\InvalidArgumentException
- name: LogicException
type: class
source: Symfony\Component\Mime\Exception\LogicException
- name: RfcComplianceException
type: class
source: Symfony\Component\Mime\Exception\RfcComplianceException
properties: []
methods:
- name: createArray
visibility: public
parameters:
- name: addresses
comment: "# * @author Fabien Potencier <fabien@symfony.com>\n# */\n# final class\
\ Address\n# {\n# /**\n# * A regex that matches a structure like 'Name <email@address.com>'.\n\
# * It matches anything between the first < and last > as email address.\n# *\
\ This allows to use a single string to construct an Address, which can be convenient\
\ to use in\n# * config, and allows to have more readable config.\n# * This does\
\ not try to cover all edge cases for address.\n# */\n# private const FROM_STRING_PATTERN\
\ = '~(?<displayName>[^<]*)<(?<addrSpec>.*)>[^>]*~';\n# \n# private static EmailValidator\
\ $validator;\n# private static IdnAddressEncoder $encoder;\n# \n# private string\
\ $address;\n# private string $name;\n# \n# public function __construct(string\
\ $address, string $name = '')\n# {\n# if (!class_exists(EmailValidator::class))\
\ {\n# throw new LogicException(\\sprintf('The \"%s\" class cannot be used as\
\ it needs \"%s\". Try running \"composer require egulias/email-validator\".',\
\ __CLASS__, EmailValidator::class));\n# }\n# \n# self::$validator ??= new EmailValidator();\n\
# \n# $this->address = trim($address);\n# $this->name = trim(str_replace([\"\\\
n\", \"\\r\"], '', $name));\n# \n# if (!self::$validator->isValid($this->address,\
\ class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation()))\
\ {\n# throw new RfcComplianceException(\\sprintf('Email \"%s\" does not comply\
\ with addr-spec of RFC 2822.', $address));\n# }\n# }\n# \n# public function getAddress():\
\ string\n# {\n# return $this->address;\n# }\n# \n# public function getName():\
\ string\n# {\n# return $this->name;\n# }\n# \n# public function getEncodedAddress():\
\ string\n# {\n# self::$encoder ??= new IdnAddressEncoder();\n# \n# return self::$encoder->encodeString($this->address);\n\
# }\n# \n# public function toString(): string\n# {\n# return ($n = $this->getEncodedName())\
\ ? $n.' <'.$this->getEncodedAddress().'>' : $this->getEncodedAddress();\n# }\n\
# \n# public function getEncodedName(): string\n# {\n# if ('' === $this->getName())\
\ {\n# return '';\n# }\n# \n# return \\sprintf('\"%s\"', preg_replace('/\"/u',\
\ '\\\"', $this->getName()));\n# }\n# \n# public static function create(self|string\
\ $address): self\n# {\n# if ($address instanceof self) {\n# return $address;\n\
# }\n# \n# if (!str_contains($address, '<')) {\n# return new self($address);\n\
# }\n# \n# if (!preg_match(self::FROM_STRING_PATTERN, $address, $matches)) {\n\
# throw new InvalidArgumentException(\\sprintf('Could not parse \"%s\" to a \"\
%s\" instance.', $address, self::class));\n# }\n# \n# return new self($matches['addrSpec'],\
\ trim($matches['displayName'], ' \\'\"'));\n# }\n# \n# /**\n# * @param array<Address|string>\
\ $addresses\n# *\n# * @return Address[]"
traits:
- Egulias\EmailValidator\EmailValidator
- Egulias\EmailValidator\Validation\MessageIDValidation
- Egulias\EmailValidator\Validation\RFCValidation
- Symfony\Component\Mime\Encoder\IdnAddressEncoder
- Symfony\Component\Mime\Exception\InvalidArgumentException
- Symfony\Component\Mime\Exception\LogicException
- Symfony\Component\Mime\Exception\RfcComplianceException
interfaces: []