mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 08:19:25 +03:00
PHP Code Sniffer
This commit is contained in:
parent
88a3e96733
commit
09eda3df13
@ -6,18 +6,21 @@ 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);
|
||||
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class InvalidCredentials extends \Exception{}
|
||||
class InvalidCredentials extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class MissingEndpoint extends \Exception{}
|
||||
class MissingEndpoint extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class MissingRequiredParameters extends \Exception{}
|
||||
class MissingRequiredParameters extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Connection\Exceptions;
|
||||
|
||||
class NoDomainsConfigured extends \Exception{}
|
||||
class NoDomainsConfigured extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ class RestClient
|
||||
{
|
||||
/**
|
||||
* Your API key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $apiKey;
|
||||
@ -37,12 +38,14 @@ class RestClient
|
||||
|
||||
/**
|
||||
* The version of the API to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $apiVersion = 'v2';
|
||||
|
||||
/**
|
||||
* If we should use SSL or not
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sslEnabled = true;
|
||||
|
@ -4,7 +4,8 @@
|
||||
namespace Mailgun\Constants;
|
||||
|
||||
|
||||
class Api {
|
||||
class Api
|
||||
{
|
||||
const API_USER = "api";
|
||||
const SDK_VERSION = "1.7";
|
||||
const SDK_USER_AGENT = "mailgun-sdk-php";
|
||||
|
@ -4,7 +4,8 @@
|
||||
namespace Mailgun\Constants;
|
||||
|
||||
|
||||
class ExceptionMessages {
|
||||
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!";
|
||||
|
@ -12,7 +12,8 @@ use Mailgun\Messages\Expcetions\InvalidParameterType;
|
||||
*
|
||||
* @link https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Lists/README.md
|
||||
*/
|
||||
class OptInHandler{
|
||||
class OptInHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $mailingList
|
||||
@ -20,7 +21,8 @@ class OptInHandler{
|
||||
* @param string $recipientAddress
|
||||
* @return string
|
||||
*/
|
||||
public function generateHash($mailingList, $secretAppId, $recipientAddress){
|
||||
public function generateHash($mailingList, $secretAppId, $recipientAddress)
|
||||
{
|
||||
$innerPayload = array('r' => $recipientAddress, 'l' => $mailingList);
|
||||
$encodedInnerPayload = base64_encode(json_encode($innerPayload));
|
||||
|
||||
@ -35,7 +37,8 @@ class OptInHandler{
|
||||
* @param string $uniqueHash
|
||||
* @return array|bool
|
||||
*/
|
||||
public function validateHash($secretAppId, $uniqueHash){
|
||||
public function validateHash($secretAppId, $uniqueHash)
|
||||
{
|
||||
$decodedOuterPayload = json_decode(base64_decode(urldecode($uniqueHash)), true);
|
||||
|
||||
$decodedHash = $decodedOuterPayload['h'];
|
||||
|
@ -16,7 +16,8 @@ use Mailgun\Messages\MessageBuilder;
|
||||
*
|
||||
* @link https://github.com/mailgun/mailgun-php/blob/master/README.md
|
||||
*/
|
||||
class Mailgun{
|
||||
class Mailgun
|
||||
{
|
||||
|
||||
/**
|
||||
* @var RestClient
|
||||
@ -53,7 +54,8 @@ class Mailgun{
|
||||
* @return \stdClass
|
||||
* @throws Exceptions\MissingRequiredMIMEParameters
|
||||
*/
|
||||
public function sendMessage($workingDomain, $postData, $postFiles = array()){
|
||||
public function sendMessage($workingDomain, $postData, $postFiles = array())
|
||||
{
|
||||
if(is_array($postFiles)) {
|
||||
return $this->post("$workingDomain/messages", $postData, $postFiles);
|
||||
}
|
||||
@ -86,7 +88,8 @@ class Mailgun{
|
||||
* @param array|null $postData
|
||||
* @return bool
|
||||
*/
|
||||
public function verifyWebhookSignature($postData = NULL) {
|
||||
public function verifyWebhookSignature($postData = null)
|
||||
{
|
||||
if($postData === null) {
|
||||
$postData = $_POST;
|
||||
}
|
||||
@ -110,7 +113,8 @@ class Mailgun{
|
||||
* @param array $files
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function post($endpointUrl, $postData = array(), $files = array()){
|
||||
public function post($endpointUrl, $postData = array(), $files = array())
|
||||
{
|
||||
return $this->restClient->post($endpointUrl, $postData, $files);
|
||||
}
|
||||
|
||||
@ -119,7 +123,8 @@ class Mailgun{
|
||||
* @param array $queryString
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function get($endpointUrl, $queryString = array()){
|
||||
public function get($endpointUrl, $queryString = array())
|
||||
{
|
||||
return $this->restClient->get($endpointUrl, $queryString);
|
||||
}
|
||||
|
||||
@ -127,7 +132,8 @@ class Mailgun{
|
||||
* @param string $endpointUrl
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function delete($endpointUrl){
|
||||
public function delete($endpointUrl)
|
||||
{
|
||||
return $this->restClient->delete($endpointUrl);
|
||||
}
|
||||
|
||||
@ -136,7 +142,8 @@ class Mailgun{
|
||||
* @param array $putData
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function put($endpointUrl, $putData){
|
||||
public function put($endpointUrl, $putData)
|
||||
{
|
||||
return $this->restClient->put($endpointUrl, $putData);
|
||||
}
|
||||
|
||||
@ -167,14 +174,16 @@ class Mailgun{
|
||||
/**
|
||||
* @return MessageBuilder
|
||||
*/
|
||||
public function MessageBuilder(){
|
||||
public function MessageBuilder()
|
||||
{
|
||||
return new MessageBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return OptInHandler
|
||||
*/
|
||||
public function OptInHandler(){
|
||||
public function OptInHandler()
|
||||
{
|
||||
return new OptInHandler();
|
||||
}
|
||||
|
||||
@ -183,7 +192,8 @@ class Mailgun{
|
||||
* @param bool $autoSend
|
||||
* @return BatchMessage
|
||||
*/
|
||||
public function BatchMessage($workingDomain, $autoSend = true){
|
||||
public function BatchMessage($workingDomain, $autoSend = true)
|
||||
{
|
||||
return new BatchMessage($this->restClient, $workingDomain, $autoSend);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ use Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters;
|
||||
*
|
||||
* @link https://github.com/mailgun/mailgun-php/blob/master/src/Mailgun/Messages/README.md
|
||||
*/
|
||||
class BatchMessage extends MessageBuilder{
|
||||
class BatchMessage extends MessageBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@ -50,7 +51,8 @@ class BatchMessage extends MessageBuilder{
|
||||
* @param string $workingDomain
|
||||
* @param boolean $autoSend
|
||||
*/
|
||||
public function __construct($restClient, $workingDomain, $autoSend){
|
||||
public function __construct($restClient, $workingDomain, $autoSend)
|
||||
{
|
||||
$this->batchRecipientAttributes = array();
|
||||
$this->autoSend = $autoSend;
|
||||
$this->restClient = $restClient;
|
||||
@ -65,7 +67,8 @@ class BatchMessage extends MessageBuilder{
|
||||
* @throws MissingRequiredMIMEParameters
|
||||
* @throws TooManyParameters
|
||||
*/
|
||||
protected function addRecipient($headerName, $address, $variables){
|
||||
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) {
|
||||
@ -101,7 +104,8 @@ class BatchMessage extends MessageBuilder{
|
||||
* @param array $files
|
||||
* @throws MissingRequiredMIMEParameters
|
||||
*/
|
||||
public function sendMessage($message = array(), $files = array()){
|
||||
public function sendMessage($message = array(), $files = array())
|
||||
{
|
||||
if(count($message) < 1) {
|
||||
$message = $this->message;
|
||||
$files = $this->files;
|
||||
@ -133,14 +137,16 @@ class BatchMessage extends MessageBuilder{
|
||||
/**
|
||||
* @throws MissingRequiredMIMEParameters
|
||||
*/
|
||||
public function finalize(){
|
||||
public function finalize()
|
||||
{
|
||||
$this->sendMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getMessageIds(){
|
||||
public function getMessageIds()
|
||||
{
|
||||
return $this->messageIds;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class InvalidParameter extends \Exception{}
|
||||
class InvalidParameter extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class InvalidParameterType extends \Exception{}
|
||||
class InvalidParameterType extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class MissingRequiredMIMEParameters extends \Exception{}
|
||||
class MissingRequiredMIMEParameters extends \Exception
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
namespace Mailgun\Messages\Exceptions;
|
||||
|
||||
class TooManyParameters extends \Exception{}
|
||||
class TooManyParameters extends \Exception
|
||||
{
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user