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

Breadcrumb

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

function EmailAddressContains::matches

Parameters

RawMessage $message:

Overrides Constraint::matches

File

vendor/symfony/mime/Test/Constraint/EmailAddressContains.php, line 35

Class

EmailAddressContains

Namespace

Symfony\Component\Mime\Test\Constraint

Code

protected function matches($message) : bool {
    if (RawMessage::class === $message::class) {
        throw new \LogicException('Unable to test a message address on a RawMessage instance.');
    }
    $header = $message->getHeaders()
        ->get($this->headerName);
    if ($header instanceof MailboxHeader) {
        return $this->expectedValue === $header->getAddress()
            ->getAddress();
    }
    elseif ($header instanceof MailboxListHeader) {
        foreach ($header->getAddresses() as $address) {
            if ($this->expectedValue === $address->getAddress()) {
                return true;
            }
        }
        return false;
    }
    throw new \LogicException('Unable to test a message address on a non-address header.');
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal