Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove dead code when setting the subject #757

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions lib/mail/EmailAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class EmailAddress implements \JsonSerializable
private $name;
/** @var $email string The email address */
private $email;
/** @var $substitutions Substitution[] An array of key/value substitutions to be be applied to the text and html content of the email body */
/** @var $substitutions Substitution[] An array of key/value substitutions
* to be be applied to the text and html content of the email body
*/
private $substitutions;
/** @var $subject Subject The personalized subject of the email */
private $subject;
Expand All @@ -40,6 +42,7 @@ class EmailAddress implements \JsonSerializable
* be be applied to the text and html content
* of the email body
* @param string|null $subject The personalized subject of the email
* @throws TypeException
*/
public function __construct(
$emailAddress = null,
Expand All @@ -65,9 +68,8 @@ public function __construct(
* Add the email address to a EmailAddress object
*
* @param string $emailAddress The email address
*
* @throws TypeException
*/
*/
public function setEmailAddress($emailAddress)
{
if (!(is_string($emailAddress) &&
Expand Down Expand Up @@ -104,9 +106,8 @@ public function getEmail()
* Add a name to a EmailAddress object
*
* @param string $name The name of the person associated with the email
*
* @throws TypeException
*/
*/
public function setName($name)
{
if (!is_string($name)) {
Expand All @@ -125,13 +126,13 @@ public function setName($name)
Double quotes will be shown in some email clients, so the name should
only be wrapped when necessary.
*/
// Only wrapp in double quote if comma or semicolon are found
// Only wrap in double quote if comma or semicolon are found
if (false !== strpos($name, ',') || false !== strpos($name, ';')) {
// Unescape quotes
$name = stripslashes(html_entity_decode($name, ENT_QUOTES));
// Escape only double quotes
$name = str_replace('"', '\\"', $name);
// Wrapp in double quotes
// Wrap in double quotes
$name = '"' . $name . '"';
}
$this->name = (!empty($name)) ? $name : null;
Expand All @@ -153,9 +154,8 @@ public function getName()
* @param array $substitutions An array of key/value substitutions to
* be be applied to the text and html content
* of the email body
*
* @throws TypeException
*/
*/
public function setSubstitutions($substitutions)
{
if (!is_array($substitutions)) {
Expand All @@ -177,23 +177,19 @@ public function getSubstitutions()
* Add a subject to a EmailAddress object
*
* @param string $subject The personalized subject of the email
*
* @throws TypeException
*/
*/
public function setSubject($subject)
{
if (!is_string($subject)) {
throw new TypeException('$subject must be of type string.');
}
if (!($subject instanceof Subject)) {
$this->subject = new Subject($subject);
} else {
$this->subject = $subject;
}
// Now that we know it is a string, we can safely create a new subject
$this->subject = new Subject($subject);
}

/**
* Retrieve a subject from a EmailAddress object
* Retrieve a subject from an EmailAddress object
*
* @return Subject
*/
Expand All @@ -203,7 +199,7 @@ public function getSubject()
}

/**
* Return an array representing a EmailAddress object for the Twilio SendGrid API
* Return an array representing an EmailAddress object for the Twilio SendGrid API
*
* @return null|array
*/
Expand Down