Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Address.php

function Address::__construct

File

vendor/symfony/mime/Address.php, line 42

Class

Address
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\Mime

Code

public function __construct(string $address, string $name = '') {
    if (!class_exists(EmailValidator::class)) {
        throw new LogicException(\sprintf('The "%s" class cannot be used as it needs "%s". Try running "composer require egulias/email-validator".', __CLASS__, EmailValidator::class));
    }
    self::$validator ??= new EmailValidator();
    $this->address = trim($address);
    $this->name = trim(str_replace([
        "\n",
        "\r",
    ], '', $name));
    if (!self::$validator->isValid($this->address, class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation())) {
        throw new RfcComplianceException(\sprintf('Email "%s" does not comply with addr-spec of RFC 2822.', $address));
    }
}
RSS feed
Powered by Drupal