/**
* @param RawMessage $message
*/
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.'
);
}