PHP CS Fixer

This commit is contained in:
David Garcia 2016-07-24 12:41:21 +01:00
parent 09eda3df13
commit 8da94ac190
16 changed files with 174 additions and 154 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Connection\Exceptions;
class GenericHTTPError extends \Exception
@ -6,7 +7,7 @@ class GenericHTTPError extends \Exception
protected $httpResponseCode;
protected $httpResponseBody;
public function __construct($message=null, $response_code=null, $response_body=null, $code=0, \Exception $previous=null)
public function __construct($message = null, $response_code = null, $response_body = null, $code = 0, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);
@ -24,5 +25,3 @@ class GenericHTTPError extends \Exception
return $this->httpResponseBody;
}
}
?>

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Connection\Exceptions;
class InvalidCredentials extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Connection\Exceptions;
class MissingEndpoint extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Connection\Exceptions;
class MissingRequiredParameters extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Connection\Exceptions;
class NoDomainsConfigured extends \Exception

View File

@ -20,7 +20,7 @@ use Psr\Http\Message\ResponseInterface;
class RestClient
{
/**
* Your API key
* Your API key.
*
* @var string
*/
@ -37,14 +37,14 @@ class RestClient
protected $apiHost;
/**
* The version of the API to use
* The version of the API to use.
*
* @var string
*/
protected $apiVersion = 'v2';
/**
* If we should use SSL or not
* If we should use SSL or not.
*
* @var bool
*/
@ -207,11 +207,11 @@ class RestClient
*/
public function responseHandler(ResponseInterface $responseObj)
{
$httpResponseCode = (int)$responseObj->getStatusCode();
$httpResponseCode = (int) $responseObj->getStatusCode();
switch ($httpResponseCode) {
case 200:
$data = (string)$responseObj->getBody();
$data = (string) $responseObj->getBody();
$jsonResponseData = json_decode($data, false);
$result = new \stdClass();
// return response data as json if possible, raw if not
@ -220,11 +220,11 @@ class RestClient
return $result;
case 400:
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS . $this->getResponseExceptionMessage($responseObj));
throw new MissingRequiredParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_PARAMETERS.$this->getResponseExceptionMessage($responseObj));
case 401:
throw new InvalidCredentials(ExceptionMessages::EXCEPTION_INVALID_CREDENTIALS);
case 404:
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT . $this->getResponseExceptionMessage($responseObj));
throw new MissingEndpoint(ExceptionMessages::EXCEPTION_MISSING_ENDPOINT.$this->getResponseExceptionMessage($responseObj));
default:
throw new GenericHTTPError(ExceptionMessages::EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
}
@ -275,9 +275,7 @@ class RestClient
];
}
/**
*
* @return HttpClient
*/
protected function getHttpClient()
@ -299,7 +297,6 @@ class RestClient
return $this->generateEndpoint($this->apiHost, $this->apiVersion, $this->sslEnabled).$uri;
}
/**
* @param string $apiEndpoint
* @param string $apiVersion
@ -309,7 +306,7 @@ class RestClient
*/
private function generateEndpoint($apiEndpoint, $apiVersion, $ssl)
{
return ($ssl ? 'https://' : 'http://') . $apiEndpoint . '/' . $apiVersion . '/';
return ($ssl ? 'https://' : 'http://').$apiEndpoint.'/'.$apiVersion.'/';
}
/**
@ -325,7 +322,7 @@ class RestClient
}
/**
* @param boolean $sslEnabled
* @param bool $sslEnabled
*
* @return RestClient
*/

View File

@ -1,17 +1,14 @@
<?php
namespace Mailgun\Constants;
class Api
{
const API_USER = "api";
const SDK_VERSION = "1.7";
const SDK_USER_AGENT = "mailgun-sdk-php";
const API_USER = 'api';
const SDK_VERSION = '1.7';
const SDK_USER_AGENT = 'mailgun-sdk-php';
const RECIPIENT_COUNT_LIMIT = 1000;
const CAMPAIGN_ID_LIMIT = 3;
const TAG_LIMIT = 3;
const DEFAULT_TIME_ZONE = "UTC";
const DEFAULT_TIME_ZONE = 'UTC';
}

View File

@ -1,22 +1,19 @@
<?php
namespace Mailgun\Constants;
class ExceptionMessages
{
const EXCEPTION_INVALID_CREDENTIALS = "Your credentials are incorrect.";
const EXCEPTION_GENERIC_HTTP_ERROR = "An HTTP Error has occurred! Check your network connection and try again.";
const EXCEPTION_MISSING_REQUIRED_PARAMETERS = "The parameters passed to the API were invalid. Check your inputs!";
const EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS = "The parameters passed to the API were invalid. Check your inputs!";
const EXCEPTION_INVALID_CREDENTIALS = 'Your credentials are incorrect.';
const EXCEPTION_GENERIC_HTTP_ERROR = 'An HTTP Error has occurred! Check your network connection and try again.';
const EXCEPTION_MISSING_REQUIRED_PARAMETERS = 'The parameters passed to the API were invalid. Check your inputs!';
const EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS = 'The parameters passed to the API were invalid. Check your inputs!';
const EXCEPTION_MISSING_ENDPOINT = "The endpoint you've tried to access does not exist. Check your URL.";
const TOO_MANY_RECIPIENTS = "You've exceeded the maximum recipient count (1,000) on the to field with autosend disabled.";
const INVALID_PARAMETER_NON_ARRAY = "The parameter you've passed in position 2 must be an array.";
const INVALID_PARAMETER_ATTACHMENT = "Attachments must be passed with an \"@\" preceding the file path. Web resources not supported.";
const INVALID_PARAMETER_INLINE = "Inline images must be passed with an \"@\" preceding the file path. Web resources not supported.";
const INVALID_PARAMETER_ATTACHMENT = 'Attachments must be passed with an "@" preceding the file path. Web resources not supported.';
const INVALID_PARAMETER_INLINE = 'Inline images must be passed with an "@" preceding the file path. Web resources not supported.';
const TOO_MANY_PARAMETERS_CAMPAIGNS = "You've exceeded the maximum (3) campaigns for a single message.";
const TOO_MANY_PARAMETERS_TAGS = "You've exceeded the maximum (3) tags for a single message.";
const TOO_MANY_PARAMETERS_RECIPIENT = "You've exceeded the maximum recipient count (1,000) on the to field with autosend disabled.";
}

View File

@ -2,10 +2,6 @@
namespace Mailgun\Lists;
use Mailgun\Messages\Exceptions\InvalidParameter;
use Mailgun\Messages\Exceptions\TooManyParameters;
use Mailgun\Messages\Expcetions\InvalidParameterType;
/**
* This class is used for creating a unique hash for
* mailing list subscription double-opt in requests.
@ -14,11 +10,11 @@ use Mailgun\Messages\Expcetions\InvalidParameterType;
*/
class OptInHandler
{
/**
* @param string $mailingList
* @param string $secretAppId
* @param string $recipientAddress
*
* @return string
*/
public function generateHash($mailingList, $secretAppId, $recipientAddress)
@ -26,7 +22,7 @@ class OptInHandler
$innerPayload = array('r' => $recipientAddress, 'l' => $mailingList);
$encodedInnerPayload = base64_encode(json_encode($innerPayload));
$innerHash = hash_hmac("sha1", $encodedInnerPayload, $secretAppId);
$innerHash = hash_hmac('sha1', $encodedInnerPayload, $secretAppId);
$outerPayload = array('h' => $innerHash, 'p' => $encodedInnerPayload);
return urlencode(base64_encode(json_encode($outerPayload)));
@ -35,6 +31,7 @@ class OptInHandler
/**
* @param string $secretAppId
* @param string $uniqueHash
*
* @return array|bool
*/
public function validateHash($secretAppId, $uniqueHash)
@ -45,9 +42,9 @@ class OptInHandler
$innerPayload = $decodedOuterPayload['p'];
$decodedInnerPayload = json_decode(base64_decode($innerPayload), true);
$computedInnerHash = hash_hmac("sha1", $innerPayload, $secretAppId);
$computedInnerHash = hash_hmac('sha1', $innerPayload, $secretAppId);
if($computedInnerHash == $decodedHash) {
if ($computedInnerHash == $decodedHash) {
return array('recipientAddress' => $decodedInnerPayload['r'], 'mailingList' => $decodedInnerPayload['l']);
}

View File

@ -18,7 +18,6 @@ use Mailgun\Messages\MessageBuilder;
*/
class Mailgun
{
/**
* @var RestClient
*/
@ -51,26 +50,26 @@ class Mailgun
* @param string $workingDomain
* @param array $postData
* @param array $postFiles
*
* @return \stdClass
*
* @throws Exceptions\MissingRequiredMIMEParameters
*/
public function sendMessage($workingDomain, $postData, $postFiles = array())
{
if(is_array($postFiles)) {
if (is_array($postFiles)) {
return $this->post("$workingDomain/messages", $postData, $postFiles);
}
else if(is_string($postFiles)) {
$tempFile = tempnam(sys_get_temp_dir(), "MG_TMP_MIME");
$fileHandle = fopen($tempFile, "w");
} elseif (is_string($postFiles)) {
$tempFile = tempnam(sys_get_temp_dir(), 'MG_TMP_MIME');
$fileHandle = fopen($tempFile, 'w');
fwrite($fileHandle, $postFiles);
$result = $this->post("$workingDomain/messages.mime", $postData, array("message" => $tempFile));
$result = $this->post("$workingDomain/messages.mime", $postData, array('message' => $tempFile));
fclose($fileHandle);
unlink($tempFile);
return $result;
}
else{
} else {
throw new Exceptions\MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
}
@ -86,24 +85,24 @@ class Mailgun
* You should reject the request with status code 403 Forbidden.
*
* @param array|null $postData
*
* @return bool
*/
public function verifyWebhookSignature($postData = null)
{
if($postData === null) {
if ($postData === null) {
$postData = $_POST;
}
if(!isset($postData['timestamp']) || !isset($postData['token']) || !isset($postData['signature'])) {
if (!isset($postData['timestamp']) || !isset($postData['token']) || !isset($postData['signature'])) {
return false;
}
$hmac = hash_hmac('sha256', "{$postData["timestamp"]}{$postData["token"]}", $this->apiKey);
$hmac = hash_hmac('sha256', "{$postData['timestamp']}{$postData['token']}", $this->apiKey);
$sig = $postData['signature'];
if(function_exists('hash_equals')) {
if (function_exists('hash_equals')) {
// hash_equals is constant time, but will not be introduced until PHP 5.6
return hash_equals($hmac, $sig);
}
else {
return ($hmac === $sig);
} else {
return $hmac === $sig;
}
}
@ -111,6 +110,7 @@ class Mailgun
* @param string $endpointUrl
* @param array $postData
* @param array $files
*
* @return \stdClass
*/
public function post($endpointUrl, $postData = array(), $files = array())
@ -121,6 +121,7 @@ class Mailgun
/**
* @param string $endpointUrl
* @param array $queryString
*
* @return \stdClass
*/
public function get($endpointUrl, $queryString = array())
@ -130,6 +131,7 @@ class Mailgun
/**
* @param string $endpointUrl
*
* @return \stdClass
*/
public function delete($endpointUrl)
@ -140,6 +142,7 @@ class Mailgun
/**
* @param string $endpointUrl
* @param array $putData
*
* @return \stdClass
*/
public function put($endpointUrl, $putData)
@ -160,7 +163,7 @@ class Mailgun
}
/**
* @param boolean $sslEnabled
* @param bool $sslEnabled
*
* @return Mailgun
*/
@ -190,6 +193,7 @@ class Mailgun
/**
* @param string $workingDomain
* @param bool $autoSend
*
* @return BatchMessage
*/
public function BatchMessage($workingDomain, $autoSend = true)

View File

@ -15,14 +15,13 @@ use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters;
*/
class BatchMessage extends MessageBuilder
{
/**
* @var array
*/
private $batchRecipientAttributes;
/**
* @var boolean
* @var bool
*/
private $autoSend;
@ -49,7 +48,7 @@ class BatchMessage extends MessageBuilder
/**
* @param \Mailgun\Connection\RestClient $restClient
* @param string $workingDomain
* @param boolean $autoSend
* @param bool $autoSend
*/
public function __construct($restClient, $workingDomain, $autoSend)
{
@ -57,21 +56,22 @@ class BatchMessage extends MessageBuilder
$this->autoSend = $autoSend;
$this->restClient = $restClient;
$this->workingDomain = $workingDomain;
$this->endpointUrl = $workingDomain . "/messages";
$this->endpointUrl = $workingDomain.'/messages';
}
/**
* @param string $headerName
* @param string $address
* @param array $variables
*
* @throws MissingRequiredMIMEParameters
* @throws TooManyParameters
*/
protected function addRecipient($headerName, $address, $variables)
{
if(array_key_exists($headerName, $this->counters['recipients'])) {
if($this->counters['recipients'][$headerName] == Api::RECIPIENT_COUNT_LIMIT) {
if($this->autoSend == false) {
if (array_key_exists($headerName, $this->counters['recipients'])) {
if ($this->counters['recipients'][$headerName] == Api::RECIPIENT_COUNT_LIMIT) {
if ($this->autoSend == false) {
throw new TooManyParameters(ExceptionMessages::TOO_MANY_RECIPIENTS);
}
$this->sendMessage();
@ -80,19 +80,17 @@ class BatchMessage extends MessageBuilder
$compiledAddress = $this->parseAddress($address, $variables);
if(isset($this->message[$headerName])) {
if (isset($this->message[$headerName])) {
array_push($this->message[$headerName], $compiledAddress);
}
elseif($headerName == "h:reply-to") {
} elseif ($headerName == 'h:reply-to') {
$this->message[$headerName] = $compiledAddress;
}
else{
} else {
$this->message[$headerName] = array($compiledAddress);
}
if(array_key_exists($headerName, $this->counters['recipients'])) {
if (array_key_exists($headerName, $this->counters['recipients'])) {
$this->counters['recipients'][$headerName] += 1;
if(!array_key_exists("id", $variables)) {
if (!array_key_exists('id', $variables)) {
$variables['id'] = $this->counters['recipients'][$headerName];
}
}
@ -102,34 +100,31 @@ class BatchMessage extends MessageBuilder
/**
* @param array $message
* @param array $files
*
* @throws MissingRequiredMIMEParameters
*/
public function sendMessage($message = array(), $files = array())
{
if(count($message) < 1) {
if (count($message) < 1) {
$message = $this->message;
$files = $this->files;
}
if(!array_key_exists("from", $message)) {
if (!array_key_exists('from', $message)) {
throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
elseif(!array_key_exists("to", $message)) {
} elseif (!array_key_exists('to', $message)) {
throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
elseif(!array_key_exists("subject", $message)) {
} elseif (!array_key_exists('subject', $message)) {
throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
elseif((!array_key_exists("text", $message) && !array_key_exists("html", $message))) {
} elseif ((!array_key_exists('text', $message) && !array_key_exists('html', $message))) {
throw new MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
}
else{
$message["recipient-variables"] = json_encode($this->batchRecipientAttributes);
} else {
$message['recipient-variables'] = json_encode($this->batchRecipientAttributes);
$response = $this->restClient->post($this->endpointUrl, $message, $files);
$this->batchRecipientAttributes = array();
$this->counters['recipients']['to'] = 0;
$this->counters['recipients']['cc'] = 0;
$this->counters['recipients']['bcc'] = 0;
unset($this->message["to"]);
unset($this->message['to']);
array_push($this->messageIds, $response->http_response_body->id);
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Messages\Exceptions;
class InvalidParameter extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Messages\Exceptions;
class InvalidParameterType extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Messages\Exceptions;
class MissingRequiredMIMEParameters extends \Exception

View File

@ -1,4 +1,5 @@
<?php
namespace Mailgun\Messages\Exceptions;
class TooManyParameters extends \Exception

View File

@ -39,20 +39,21 @@ class MessageBuilder
'recipients' => array(
'to' => 0,
'cc' => 0,
'bcc' => 0
'bcc' => 0,
),
'attributes' => array(
'attachment' => 0,
'campaign_id' => 0,
'custom_option' => 0,
'tag' => 0
)
'tag' => 0,
),
);
/**
* @param array $params
* @param string $key
* @param mixed $default
*
* @return mixed
*/
protected function safeGet($params, $key, $default)
@ -66,23 +67,25 @@ class MessageBuilder
/**
* @param array $params
*
* @return mixed|string
*/
protected function getFullName($params)
{
if (array_key_exists("first", $params)) {
$first = $this->safeGet($params, "first", "");
$last = $this->safeGet($params, "last", "");
if (array_key_exists('first', $params)) {
$first = $this->safeGet($params, 'first', '');
$last = $this->safeGet($params, 'last', '');
return trim("$first $last");
}
return $this->safeGet($params, "full_name", "");
return $this->safeGet($params, 'full_name', '');
}
/**
* @param string $address
* @param array $variables
*
* @return string
*/
protected function parseAddress($address, $variables)
@ -109,7 +112,7 @@ class MessageBuilder
if (isset($this->message[$headerName])) {
array_push($this->message[$headerName], $compiledAddress);
} elseif ($headerName == "h:reply-to") {
} elseif ($headerName == 'h:reply-to') {
$this->message[$headerName] = $compiledAddress;
} else {
$this->message[$headerName] = array($compiledAddress);
@ -122,7 +125,9 @@ class MessageBuilder
/**
* @param string $address
* @param array|null $variables
*
* @return mixed
*
* @throws TooManyParameters
*/
public function addToRecipient($address, $variables = null)
@ -130,7 +135,7 @@ class MessageBuilder
if ($this->counters['recipients']['to'] > Api::RECIPIENT_COUNT_LIMIT) {
throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT);
}
$this->addRecipient("to", $address, $variables);
$this->addRecipient('to', $address, $variables);
return end($this->message['to']);
}
@ -138,7 +143,9 @@ class MessageBuilder
/**
* @param string $address
* @param array|null $variables
*
* @return mixed
*
* @throws TooManyParameters
*/
public function addCcRecipient($address, $variables = null)
@ -146,7 +153,7 @@ class MessageBuilder
if ($this->counters['recipients']['cc'] > Api::RECIPIENT_COUNT_LIMIT) {
throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT);
}
$this->addRecipient("cc", $address, $variables);
$this->addRecipient('cc', $address, $variables);
return end($this->message['cc']);
}
@ -154,7 +161,9 @@ class MessageBuilder
/**
* @param string $address
* @param array|null $variables
*
* @return mixed
*
* @throws TooManyParameters
*/
public function addBccRecipient($address, $variables = null)
@ -162,7 +171,7 @@ class MessageBuilder
if ($this->counters['recipients']['bcc'] > Api::RECIPIENT_COUNT_LIMIT) {
throw new TooManyParameters(ExceptionMessages::TOO_MANY_PARAMETERS_RECIPIENT);
}
$this->addRecipient("bcc", $address, $variables);
$this->addRecipient('bcc', $address, $variables);
return end($this->message['bcc']);
}
@ -170,11 +179,12 @@ class MessageBuilder
/**
* @param string $address
* @param array|null $variables
*
* @return mixed
*/
public function setFromAddress($address, $variables = null)
{
$this->addRecipient("from", $address, $variables);
$this->addRecipient('from', $address, $variables);
return $this->message['from'];
}
@ -182,23 +192,25 @@ class MessageBuilder
/**
* @param string $address
* @param array|null $variables
*
* @return mixed
*/
public function setReplyToAddress($address, $variables = null)
{
$this->addRecipient("h:reply-to", $address, $variables);
$this->addRecipient('h:reply-to', $address, $variables);
return $this->message['h:reply-to'];
}
/**
* @param string $subject
*
* @return mixed
*/
public function setSubject($subject = "")
public function setSubject($subject = '')
{
if ($subject == null || $subject == "") {
$subject = " ";
if ($subject == null || $subject == '') {
$subject = ' ';
}
$this->message['subject'] = $subject;
@ -208,12 +220,13 @@ class MessageBuilder
/**
* @param string $headerName
* @param mixed $headerData
*
* @return mixed
*/
public function addCustomHeader($headerName, $headerData)
{
if (!preg_match("/^h:/i", $headerName)) {
$headerName = "h:" . $headerName;
if (!preg_match('/^h:/i', $headerName)) {
$headerName = 'h:'.$headerName;
}
$this->message[$headerName] = array($headerData);
@ -222,12 +235,13 @@ class MessageBuilder
/**
* @param string $textBody
*
* @return string
*/
public function setTextBody($textBody)
{
if ($textBody == null || $textBody == "") {
$textBody = " ";
if ($textBody == null || $textBody == '') {
$textBody = ' ';
}
$this->message['text'] = $textBody;
@ -236,12 +250,13 @@ class MessageBuilder
/**
* @param string $htmlBody
*
* @return string
*/
public function setHtmlBody($htmlBody)
{
if ($htmlBody == null || $htmlBody == "") {
$htmlBody = " ";
if ($htmlBody == null || $htmlBody == '') {
$htmlBody = ' ';
}
$this->message['html'] = $htmlBody;
@ -251,22 +266,23 @@ class MessageBuilder
/**
* @param string $attachmentPath
* @param string|null $attachmentName
*
* @return bool
*/
public function addAttachment($attachmentPath, $attachmentName = null)
{
if (isset($this->files["attachment"])) {
if (isset($this->files['attachment'])) {
$attachment = array(
'filePath' => $attachmentPath,
'remoteName' => $attachmentName
'remoteName' => $attachmentName,
);
array_push($this->files["attachment"], $attachment);
array_push($this->files['attachment'], $attachment);
} else {
$this->files["attachment"] = array(
$this->files['attachment'] = array(
array(
'filePath' => $attachmentPath,
'remoteName' => $attachmentName
)
'remoteName' => $attachmentName,
),
);
}
@ -278,6 +294,7 @@ class MessageBuilder
* @param string|null $inlineImageName
*
* @return bool|true
*
* @throws InvalidParameter
*/
public function addInlineImage($inlineImagePath, $inlineImageName = null)
@ -286,15 +303,15 @@ class MessageBuilder
if (isset($this->files['inline'])) {
$inlineAttachment = array(
'filePath' => $inlineImagePath,
'remoteName' => $inlineImageName
'remoteName' => $inlineImageName,
);
array_push($this->files['inline'], $inlineAttachment);
} else {
$this->files['inline'] = array(
array(
'filePath' => $inlineImagePath,
'remoteName' => $inlineImageName
)
'remoteName' => $inlineImageName,
),
);
}
@ -305,15 +322,16 @@ class MessageBuilder
}
/**
* @param boolean $testMode
* @param bool $testMode
*
* @return string
*/
public function setTestMode($testMode)
{
if (filter_var($testMode, FILTER_VALIDATE_BOOLEAN)) {
$testMode = "yes";
$testMode = 'yes';
} else {
$testMode = "no";
$testMode = 'no';
}
$this->message['o:testmode'] = $testMode;
@ -322,7 +340,9 @@ class MessageBuilder
/**
* @param string|int $campaignId
*
* @return string|int
*
* @throws TooManyParameters
*/
public function addCampaignId($campaignId)
@ -343,6 +363,7 @@ class MessageBuilder
/**
* @param string $tag
*
* @throws TooManyParameters
*/
public function addTag($tag)
@ -362,31 +383,33 @@ class MessageBuilder
}
/**
* @param boolean $enabled
* @param bool $enabled
*
* @return mixed
*/
public function setDkim($enabled)
{
if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) {
$enabled = "yes";
$enabled = 'yes';
} else {
$enabled = "no";
$enabled = 'no';
}
$this->message["o:dkim"] = $enabled;
$this->message['o:dkim'] = $enabled;
return $this->message["o:dkim"];
return $this->message['o:dkim'];
}
/**
* @param boolean $enabled
* @param bool $enabled
*
* @return string
*/
public function setOpenTracking($enabled)
{
if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) {
$enabled = "yes";
$enabled = 'yes';
} else {
$enabled = "no";
$enabled = 'no';
}
$this->message['o:tracking-opens'] = $enabled;
@ -394,17 +417,18 @@ class MessageBuilder
}
/**
* @param boolean $enabled
* @param bool $enabled
*
* @return string
*/
public function setClickTracking($enabled)
{
if (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) {
$enabled = "yes";
} elseif ($enabled == "html") {
$enabled = "html";
$enabled = 'yes';
} elseif ($enabled == 'html') {
$enabled = 'html';
} else {
$enabled = "no";
$enabled = 'no';
}
$this->message['o:tracking-clicks'] = $enabled;
@ -414,6 +438,7 @@ class MessageBuilder
/**
* @param string $timeDate
* @param string|null $timeZone
*
* @return string
*/
public function setDeliveryTime($timeDate, $timeZone = null)
@ -437,12 +462,13 @@ class MessageBuilder
*/
public function addCustomData($customName, $data)
{
$this->message['v:' . $customName] = json_encode($data);
$this->message['v:'.$customName] = json_encode($data);
}
/**
* @param string $parameterName
* @param mixed $data
*
* @return mixed
*/
public function addCustomParameter($parameterName, $data)