From 8da94ac19013fc4297de226e1dc4ac29c544df01 Mon Sep 17 00:00:00 2001 From: David Garcia Date: Sun, 24 Jul 2016 12:41:21 +0100 Subject: [PATCH] PHP CS Fixer --- .../Exceptions/GenericHTTPError.php | 17 +-- .../Exceptions/InvalidCredentials.php | 1 + .../Connection/Exceptions/MissingEndpoint.php | 1 + .../Exceptions/MissingRequiredParameters.php | 1 + .../Exceptions/NoDomainsConfigured.php | 1 + src/Mailgun/Connection/RestClient.php | 21 ++- src/Mailgun/Constants/Api.php | 11 +- src/Mailgun/Constants/ExceptionMessages.php | 15 +- src/Mailgun/Lists/OptInHandler.php | 13 +- src/Mailgun/Mailgun.php | 50 +++--- src/Mailgun/Messages/BatchMessage.php | 51 +++---- .../Messages/Exceptions/InvalidParameter.php | 1 + .../Exceptions/InvalidParameterType.php | 1 + .../MissingRequiredMIMEParameters.php | 1 + .../Messages/Exceptions/TooManyParameters.php | 1 + src/Mailgun/Messages/MessageBuilder.php | 142 +++++++++++------- 16 files changed, 174 insertions(+), 154 deletions(-) diff --git a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php index 35439d8..20ebd96 100644 --- a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php +++ b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php @@ -1,28 +1,27 @@ httpResponseCode = $response_code; $this->httpResponseBody = $response_body; } - - public function getHttpResponseCode() + + public function getHttpResponseCode() { return $this->httpResponseCode; } - - public function getHttpResponseBody() + + public function getHttpResponseBody() { return $this->httpResponseBody; } } - -?> diff --git a/src/Mailgun/Connection/Exceptions/InvalidCredentials.php b/src/Mailgun/Connection/Exceptions/InvalidCredentials.php index b890ca7..d7159d5 100644 --- a/src/Mailgun/Connection/Exceptions/InvalidCredentials.php +++ b/src/Mailgun/Connection/Exceptions/InvalidCredentials.php @@ -1,4 +1,5 @@ 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 */ diff --git a/src/Mailgun/Constants/Api.php b/src/Mailgun/Constants/Api.php index 32a1dea..a3ffdfb 100644 --- a/src/Mailgun/Constants/Api.php +++ b/src/Mailgun/Constants/Api.php @@ -1,17 +1,14 @@ $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']); } diff --git a/src/Mailgun/Mailgun.php b/src/Mailgun/Mailgun.php index f6478f0..6fed34e 100644 --- a/src/Mailgun/Mailgun.php +++ b/src/Mailgun/Mailgun.php @@ -18,7 +18,6 @@ use Mailgun\Messages\MessageBuilder; */ class Mailgun { - /** * @var RestClient */ @@ -48,29 +47,29 @@ class Mailgun * MIME string. If sending MIME, the string must be passed in to the 3rd * position of the function call. * - * @param string $workingDomain - * @param array $postData - * @param array $postFiles + * @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); } } @@ -85,25 +84,25 @@ class Mailgun * If this function returns FALSE, you must not process the request. * You should reject the request with status code 403 Forbidden. * - * @param array|null $postData + * @param array|null $postData + * * @return bool */ - public function verifyWebhookSignature($postData = null) + 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) diff --git a/src/Mailgun/Messages/BatchMessage.php b/src/Mailgun/Messages/BatchMessage.php index 53d7d97..9bfbb22 100644 --- a/src/Mailgun/Messages/BatchMessage.php +++ b/src/Mailgun/Messages/BatchMessage.php @@ -15,14 +15,13 @@ use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters; */ class BatchMessage extends MessageBuilder { - /** * @var array */ private $batchRecipientAttributes; /** - * @var boolean + * @var bool */ private $autoSend; @@ -40,16 +39,16 @@ class BatchMessage extends MessageBuilder * @var array */ private $messageIds = array(); - + /** - * @var string + * @var string */ private $endpointUrl; /** * @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); } } diff --git a/src/Mailgun/Messages/Exceptions/InvalidParameter.php b/src/Mailgun/Messages/Exceptions/InvalidParameter.php index 33c9070..06c8612 100644 --- a/src/Mailgun/Messages/Exceptions/InvalidParameter.php +++ b/src/Mailgun/Messages/Exceptions/InvalidParameter.php @@ -1,4 +1,5 @@ array( - 'to' => 0, - 'cc' => 0, - 'bcc' => 0 + 'to' => 0, + 'cc' => 0, + 'bcc' => 0, ), 'attributes' => array( - 'attachment' => 0, - 'campaign_id' => 0, + '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 + 'filePath' => $attachmentPath, + '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 - ) + 'filePath' => $attachmentPath, + 'remoteName' => $attachmentName, + ), ); } @@ -278,6 +294,7 @@ class MessageBuilder * @param string|null $inlineImageName * * @return bool|true + * * @throws InvalidParameter */ public function addInlineImage($inlineImagePath, $inlineImageName = null) @@ -285,16 +302,16 @@ class MessageBuilder if (strpos($inlineImagePath, '@') === 0) { if (isset($this->files['inline'])) { $inlineAttachment = array( - 'filePath' => $inlineImagePath, - 'remoteName' => $inlineImageName + 'filePath' => $inlineImagePath, + 'remoteName' => $inlineImageName, ); array_push($this->files['inline'], $inlineAttachment); } else { $this->files['inline'] = array( array( - 'filePath' => $inlineImagePath, - 'remoteName' => $inlineImageName - ) + 'filePath' => $inlineImagePath, + '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) @@ -424,8 +449,8 @@ class MessageBuilder $timeZoneObj = new \DateTimeZone(Api::DEFAULT_TIME_ZONE); } - $dateTimeObj = new \DateTime($timeDate, $timeZoneObj); - $formattedTimeDate = $dateTimeObj->format(\DateTime::RFC2822); + $dateTimeObj = new \DateTime($timeDate, $timeZoneObj); + $formattedTimeDate = $dateTimeObj->format(\DateTime::RFC2822); $this->message['o:deliverytime'] = $formattedTimeDate; return $this->message['o:deliverytime']; @@ -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)