Skip to content

Commit

Permalink
Merge pull request laminas#149 from glensc/use-class-constant
Browse files Browse the repository at this point in the history
QA: Use ::class constant for getHeaderByName() calls
  • Loading branch information
Slamdunk authored May 4, 2021
2 parents d7a1398 + 63c5eee commit 3fc6820
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@

namespace Laminas\Mail;

use Laminas\Mail\Header\Bcc;
use Laminas\Mail\Header\Cc;
use Laminas\Mail\Header\ContentType;
use Laminas\Mail\Header\From;
use Laminas\Mail\Header\MimeVersion;
use Laminas\Mail\Header\ReplyTo;
use Laminas\Mail\Header\Sender;
use Laminas\Mail\Header\To;
use Laminas\Mime;
use Traversable;

Expand Down Expand Up @@ -139,7 +145,7 @@ public function addFrom($emailOrAddressOrList, $name = null)
*/
public function getFrom()
{
return $this->getAddressListFromHeader('from', __NAMESPACE__ . '\Header\From');
return $this->getAddressListFromHeader('from', From::class);
}

/**
Expand Down Expand Up @@ -178,7 +184,7 @@ public function addTo($emailOrAddressOrList, $name = null)
*/
public function getTo()
{
return $this->getAddressListFromHeader('to', __NAMESPACE__ . '\Header\To');
return $this->getAddressListFromHeader('to', To::class);
}

/**
Expand Down Expand Up @@ -215,7 +221,7 @@ public function addCc($emailOrAddressOrList, $name = null)
*/
public function getCc()
{
return $this->getAddressListFromHeader('cc', __NAMESPACE__ . '\Header\Cc');
return $this->getAddressListFromHeader('cc', Cc::class);
}

/**
Expand Down Expand Up @@ -252,7 +258,7 @@ public function addBcc($emailOrAddressOrList, $name = null)
*/
public function getBcc()
{
return $this->getAddressListFromHeader('bcc', __NAMESPACE__ . '\Header\Bcc');
return $this->getAddressListFromHeader('bcc', Bcc::class);
}

/**
Expand Down Expand Up @@ -291,7 +297,7 @@ public function addReplyTo($emailOrAddressOrList, $name = null)
*/
public function getReplyTo()
{
return $this->getAddressListFromHeader('reply-to', __NAMESPACE__ . '\Header\ReplyTo');
return $this->getAddressListFromHeader('reply-to', ReplyTo::class);
}

/**
Expand All @@ -304,7 +310,7 @@ public function getReplyTo()
public function setSender($emailOrAddress, $name = null)
{
/** @var Sender $header */
$header = $this->getHeaderByName('sender', __NAMESPACE__ . '\Header\Sender');
$header = $this->getHeaderByName('sender', Sender::class);
$header->setAddress($emailOrAddress, $name);
return $this;
}
Expand All @@ -322,7 +328,7 @@ public function getSender()
}

/** @var Sender $header */
$header = $this->getHeaderByName('sender', __NAMESPACE__ . '\Header\Sender');
$header = $this->getHeaderByName('sender', Sender::class);
return $header->getAddress();
}

Expand Down Expand Up @@ -398,14 +404,14 @@ public function setBody($body)

// Get headers, and set Mime-Version header
$headers = $this->getHeaders();
$this->getHeaderByName('mime-version', __NAMESPACE__ . '\Header\MimeVersion');
$this->getHeaderByName('mime-version', MimeVersion::class);

// Multipart content headers
if ($this->body->isMultiPart()) {
$mime = $this->body->getMime();

/** @var ContentType $header */
$header = $this->getHeaderByName('content-type', __NAMESPACE__ . '\Header\ContentType');
$header = $this->getHeaderByName('content-type', ContentType::class);
$header->setType('multipart/mixed');
$header->addParameter('boundary', $mime->boundary());
return $this;
Expand Down

0 comments on commit 3fc6820

Please sign in to comment.