function EmailAddressContains::matches
Parameters
RawMessage $message:
Overrides Constraint::matches
File
-
vendor/
symfony/ mime/ Test/ Constraint/ EmailAddressContains.php, line 35
Class
Namespace
Symfony\Component\Mime\Test\ConstraintCode
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.');
}