diff --git a/examples/available-phone-numbers-view.php b/examples/available-phone-numbers-view.php index b72e542f..c119ae16 100644 --- a/examples/available-phone-numbers-view.php +++ b/examples/available-phone-numbers-view.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('MESSAGEBIRD_API_KEY'); try { - $phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", array()); + $phoneNumbers = $MessageBird->availablePhoneNumbers->getList("nl", []); var_dump($phoneNumbers); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/chatchannels-create.php b/examples/chatchannels-create.php index f5359379..1fa88f6a 100644 --- a/examples/chatchannels-create.php +++ b/examples/chatchannels-create.php @@ -15,10 +15,10 @@ // are required when creating a channel for this platform. $ChatChannel->channelDetails = - array( + [ 'botName' => 'testBot', 'token' => '1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA' - ); + ]; try { $ChatChannelResult = $MessageBird->chatChannels->create($ChatChannel); diff --git a/examples/contact-list.php b/examples/contact-list.php index 32d1cc38..ff41d2c3 100644 --- a/examples/contact-list.php +++ b/examples/contact-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $ContactList = $MessageBird->contacts->getList(array ()); + $ContactList = $MessageBird->contacts->getList( []); var_dump($ContactList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/conversations/create-hsm.php b/examples/conversations/create-hsm.php index 6fda1e06..881045d5 100644 --- a/examples/conversations/create-hsm.php +++ b/examples/conversations/create-hsm.php @@ -20,7 +20,7 @@ $hsm = new \MessageBird\Objects\Conversation\HSM\Message(); $hsm->templateName = 'YOUR TEMPLATE NAME'; $hsm->namespace = 'YOUR NAMESPACE'; -$hsm->params = array($hsmParam1, $hsmParam2); +$hsm->params = [$hsmParam1, $hsmParam2]; $hsm->language = $hsmLanguage; $content = new \MessageBird\Objects\Conversation\Content(); diff --git a/examples/conversations/list.php b/examples/conversations/list.php index 5c37408c..b6a9f429 100644 --- a/examples/conversations/list.php +++ b/examples/conversations/list.php @@ -8,10 +8,10 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. // Take 10 objects, but skip the first 5. -$optionalParameters = array( +$optionalParameters = [ 'limit' => '10', 'offset' => '5', -); +]; try { $conversations = $messageBird->conversations->getList($optionalParameters); diff --git a/examples/conversations/messages-create-location.php b/examples/conversations/messages-create-location.php index 769adc73..8d27e06e 100644 --- a/examples/conversations/messages-create-location.php +++ b/examples/conversations/messages-create-location.php @@ -7,10 +7,10 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. $content = new \MessageBird\Objects\Conversation\Content(); -$content->location = array( +$content->location = [ 'latitude' => 52.379112, 'longitude' => 4.900384, -); +]; $message = new \MessageBird\Objects\Conversation\Message(); $message->channelId = 'CHANNEL_ID'; diff --git a/examples/conversations/messages-create-media.php b/examples/conversations/messages-create-media.php index fff236b3..47494583 100644 --- a/examples/conversations/messages-create-media.php +++ b/examples/conversations/messages-create-media.php @@ -8,9 +8,9 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. $content = new \MessageBird\Objects\Conversation\Content(); -$content->image = array( +$content->image = [ 'url' => 'https://cdn-gc.messagebird.com/assets/images/logo.png' -); +]; $message = new \MessageBird\Objects\Conversation\Message(); $message->channelId = 'CHANNEL_ID'; diff --git a/examples/conversations/read.php b/examples/conversations/read.php index d2a375df..0f0b36c3 100644 --- a/examples/conversations/read.php +++ b/examples/conversations/read.php @@ -8,9 +8,9 @@ // Setting the optional 'include' parameter to 'content' requests the API to // include the expanded Contact object in its response. Excluded by default. -$optionalParameters = array( +$optionalParameters = [ 'include' => 'content', -); +]; try { $conversation = $messageBird->conversations->read( diff --git a/examples/conversations/webhooks-create.php b/examples/conversations/webhooks-create.php index 08c2e298..43dd949b 100644 --- a/examples/conversations/webhooks-create.php +++ b/examples/conversations/webhooks-create.php @@ -13,14 +13,14 @@ $webhook = new \MessageBird\Objects\Conversation\Webhook(); $webhook->channelId = 'CHANNEL_ID'; $webhook->url = 'https://example.com/webhook'; - $webhook->events = array( + $webhook->events = [ \MessageBird\Objects\Conversation\Webhook::EVENT_CONVERSATION_CREATED, \MessageBird\Objects\Conversation\Webhook::EVENT_MESSAGE_CREATED, // Other options: // \MessageBird\Objects\Conversation\Webhook::EVENT_CONVERSATION_UPDATED, // \MessageBird\Objects\Conversation\Webhook::EVENT_MESSAGE_UPDATED, - ); + ]; $messageBird->conversationWebhooks->create($webhook); } catch (\Exception $e) { diff --git a/examples/group-add-contact-to-group.php b/examples/group-add-contact-to-group.php index a6f23b08..46b3dbec 100644 --- a/examples/group-add-contact-to-group.php +++ b/examples/group-add-contact-to-group.php @@ -5,10 +5,10 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $contacts['ids'] = array( + $contacts['ids'] = [ 'contact_id_1', 'contact_id_2', - ); + ]; $group_id = 'group_id'; $GroupAddContact = $MessageBird->groups->addContacts($contacts, $group_id); var_dump($GroupAddContact); diff --git a/examples/group-list.php b/examples/group-list.php index 3eebb5b0..e6451fa5 100644 --- a/examples/group-list.php +++ b/examples/group-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $GroupsList = $MessageBird->groups->getList(array ()); + $GroupsList = $MessageBird->groups->getList( []); var_dump($GroupsList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/hlr-list.php b/examples/hlr-list.php index c35648da..86e56bdf 100644 --- a/examples/hlr-list.php +++ b/examples/hlr-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $HlrList = $MessageBird->hlr->getList(array ('offset' => 100, 'limit' => 30)); + $HlrList = $MessageBird->hlr->getList( ['offset' => 100, 'limit' => 30]); var_dump($HlrList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/message-create-unicode.php b/examples/message-create-unicode.php index 0b7b736c..f631fcc7 100644 --- a/examples/message-create-unicode.php +++ b/examples/message-create-unicode.php @@ -6,7 +6,7 @@ $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; -$Message->recipients = array(31612345678); +$Message->recipients = [31612345678]; $Message->body = 'This is a test message with a smiling emoji 😀.'; $Message->datacoding = 'unicode'; diff --git a/examples/message-create.php b/examples/message-create.php index 5f5fd498..988282c9 100644 --- a/examples/message-create.php +++ b/examples/message-create.php @@ -6,7 +6,7 @@ $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; -$Message->recipients = array(31612345678); +$Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; try { diff --git a/examples/message-list.php b/examples/message-list.php index 3e207677..c006b9ce 100644 --- a/examples/message-list.php +++ b/examples/message-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $MessageList = $MessageBird->messages->getList(array ('offset' => 100, 'limit' => 30)); + $MessageList = $MessageBird->messages->getList( ['offset' => 100, 'limit' => 30]); var_dump($MessageList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/examples/mms-create.php b/examples/mms-create.php index 457b0e50..0d9dd91c 100644 --- a/examples/mms-create.php +++ b/examples/mms-create.php @@ -6,10 +6,10 @@ $MmsMessage = new \MessageBird\Objects\MmsMessage(); $MmsMessage->originator = 'MessageBird'; -$MmsMessage->recipients = array(31612345678); +$MmsMessage->recipients = [31612345678]; $MmsMessage->subject = "Check out this cool MMS"; $MmsMessage->body = 'Have you seen this logo?'; -$MmsMessage->mediaUrls = array('https://www.messagebird.com/assets/images/og/messagebird.gif'); +$MmsMessage->mediaUrls = ['https://www.messagebird.com/assets/images/og/messagebird.gif']; try { $MmsMessageResult = $MessageBird->mmsMessages->create($MmsMessage); diff --git a/examples/mms-list.php b/examples/mms-list.php index 1958a02b..5bf94ca1 100644 --- a/examples/mms-list.php +++ b/examples/mms-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $MmsList = $MessageBird->mmsMessages->getList(array('offset' => 0, 'limit' => 30)); + $MmsList = $MessageBird->mmsMessages->getList(['offset' => 0, 'limit' => 30]); var_dump($MmsList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { // That means that your accessKey is unknown diff --git a/examples/phone-numbers-update.php b/examples/phone-numbers-update.php index 08bdb464..f2b1e0d6 100644 --- a/examples/phone-numbers-update.php +++ b/examples/phone-numbers-update.php @@ -4,7 +4,7 @@ $MessageBird = new \MessageBird\Client('MESSAGEBIRD_API_KEY'); // Set your own API access key here. $Number = new \MessageBird\Objects\Number(); -$Number->tags = array('tag1'); +$Number->tags = ['tag1']; try { $NumberResult = $MessageBird->phoneNumbers->update($Number, '31612345678'); diff --git a/examples/verify-create.php b/examples/verify-create.php index 4a9aab9f..d7aa2179 100644 --- a/examples/verify-create.php +++ b/examples/verify-create.php @@ -7,10 +7,10 @@ $Verify = new \MessageBird\Objects\Verify(); $Verify->recipient = 31612345678; -$extraOptions = array( +$extraOptions = [ 'originator' => 'MessageBird', 'timeout' => 60, -); +]; try { $VerifyResult = $MessageBird->verify->create($Verify, $extraOptions); diff --git a/examples/voice-call-flows-create.php b/examples/voice-call-flows-create.php index b4e94349..8b7f30d2 100644 --- a/examples/voice-call-flows-create.php +++ b/examples/voice-call-flows-create.php @@ -7,12 +7,12 @@ $callFlow->title = 'Foobar'; $step = new \MessageBird\Objects\Voice\Step(); $step->action = 'say'; -$step->options = array( +$step->options = [ 'payload' => 'This is a journey into sound.', 'language' => 'en-GB', 'voice' => 'male', -); -$callFlow->steps = array($step); +]; +$callFlow->steps = [$step]; try { $result = $messageBird->voiceCallFlows->create($callFlow); diff --git a/examples/voice-call-flows-list.php b/examples/voice-call-flows-list.php index 886ab582..16e890e9 100644 --- a/examples/voice-call-flows-list.php +++ b/examples/voice-call-flows-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceCallFlows->getList(array('offset' => 100, 'limit' => 30)); + $result = $messageBird->voiceCallFlows->getList(['offset' => 100, 'limit' => 30]); var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voice-calls-create.php b/examples/voice-calls-create.php index 6b9d9c5a..16cef429 100644 --- a/examples/voice-calls-create.php +++ b/examples/voice-calls-create.php @@ -10,12 +10,12 @@ $callFlow->title = 'Say message'; $step = new \MessageBird\Objects\Voice\Step(); $step->action = 'say'; -$step->options = array( +$step->options = [ 'payload' => 'This is a journey into sound.', 'language' => 'en-GB', 'voice' => 'male', -); -$callFlow->steps = array($step); +]; +$callFlow->steps = [$step]; $call->callFlow = $callFlow; try { diff --git a/examples/voice-calls-list.php b/examples/voice-calls-list.php index 7deb377a..00f495f1 100644 --- a/examples/voice-calls-list.php +++ b/examples/voice-calls-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceCalls->getList(array('offset' => 100, 'limit' => 30)); + $result = $messageBird->voiceCalls->getList(['offset' => 100, 'limit' => 30]); var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voice-legs-list.php b/examples/voice-legs-list.php index b718a5a7..e61be0e0 100644 --- a/examples/voice-legs-list.php +++ b/examples/voice-legs-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceLegs->getList('dbf1373c-6781-43c7-bfe4-6538583c444b', array('offset' => 100, 'limit' => 30)); // Set a call id here + $result = $messageBird->voiceLegs->getList('dbf1373c-6781-43c7-bfe4-6538583c444b', ['offset' => 100, 'limit' => 30]); // Set a call id here var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voice-recordings-list.php b/examples/voice-recordings-list.php index 12f773f7..99d962ff 100644 --- a/examples/voice-recordings-list.php +++ b/examples/voice-recordings-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceRecordings->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', array('offset' => 100, 'limit' => 30)); // Set a call and leg id here + $result = $messageBird->voiceRecordings->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', ['offset' => 100, 'limit' => 30]); // Set a call and leg id here var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voice-transcriptions-list.php b/examples/voice-transcriptions-list.php index 71e8bde4..9c35bf8b 100644 --- a/examples/voice-transcriptions-list.php +++ b/examples/voice-transcriptions-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceTranscriptions->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', 'a94f7d51-19b5-4eb8-9e8e-90fce490a577', array('offset' => 100, 'limit' => 30)); // Set a call and leg id here + $result = $messageBird->voiceTranscriptions->getList('c226420d-f107-4db1-b2f9-4646656a90bc', '4f5ab5f4-c4b6-4586-9255-980bb3fd7336', 'a94f7d51-19b5-4eb8-9e8e-90fce490a577', ['offset' => 100, 'limit' => 30]); // Set a call and leg id here var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voice-webhooks-list.php b/examples/voice-webhooks-list.php index 452529aa..6cc31e04 100644 --- a/examples/voice-webhooks-list.php +++ b/examples/voice-webhooks-list.php @@ -5,7 +5,7 @@ $messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $result = $messageBird->voiceWebhooks->getList(array('offset' => 100, 'limit' => 30)); + $result = $messageBird->voiceWebhooks->getList(['offset' => 100, 'limit' => 30]); var_dump($result); } catch (\Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); diff --git a/examples/voicemessages-create.php b/examples/voicemessages-create.php index 96d6277a..330e26fb 100644 --- a/examples/voicemessages-create.php +++ b/examples/voicemessages-create.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. $VoiceMessage = new \MessageBird\Objects\VoiceMessage(); -$VoiceMessage->recipients = array (31654286496); +$VoiceMessage->recipients = [31654286496]; $VoiceMessage->body = 'This is a test message. The message is converted to speech and the recipient is called on his mobile.'; $VoiceMessage->language = 'en-gb'; $VoiceMessage->voice = 'female'; diff --git a/examples/voicemessages-list.php b/examples/voicemessages-list.php index 1fe29430..dab7537d 100644 --- a/examples/voicemessages-list.php +++ b/examples/voicemessages-list.php @@ -5,7 +5,7 @@ $MessageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here. try { - $VoiceMessageList = $MessageBird->voicemessages->getList(array ('offset' => 100, 'limit' => 30)); + $VoiceMessageList = $MessageBird->voicemessages->getList( ['offset' => 100, 'limit' => 30]); var_dump($VoiceMessageList); } catch (\MessageBird\Exceptions\AuthenticateException $e) { diff --git a/src/MessageBird/Client.php b/src/MessageBird/Client.php index 62cf5065..853ecddb 100644 --- a/src/MessageBird/Client.php +++ b/src/MessageBird/Client.php @@ -196,9 +196,9 @@ public function __construct($accessKey = null, Common\HttpClient $httpClient = n $this->ChatAPIHttpClient = new Common\HttpClient(self::CHATAPI_ENDPOINT); $this->ConversationsAPIHttpClient = new Common\HttpClient(in_array(self::ENABLE_CONVERSATIONSAPI_WHATSAPP_SANDBOX, $config) ? self::CONVERSATIONSAPI_WHATSAPP_SANDBOX_ENDPOINT : self::CONVERSATIONSAPI_ENDPOINT); $this->HttpClient = new Common\HttpClient(self::ENDPOINT); - $this->VoiceAPIHttpClient = new Common\HttpClient(self::VOICEAPI_ENDPOINT, 10, 2, array( + $this->VoiceAPIHttpClient = new Common\HttpClient(self::VOICEAPI_ENDPOINT, 10, 2, [ 'X-MessageBird-Version' => '20170314', - )); + ]); $this->partnerAccountClient = new Common\HttpClient(self::PARTNER_ACCOUNT_ENDPOINT); $this->numbersAPIClient = new Common\HttpClient(self::NUMBERSAPI_ENDPOINT); } else { diff --git a/src/MessageBird/Common/HttpClient.php b/src/MessageBird/Common/HttpClient.php index b9a03cf7..8a0bb831 100644 --- a/src/MessageBird/Common/HttpClient.php +++ b/src/MessageBird/Common/HttpClient.php @@ -28,7 +28,7 @@ class HttpClient /** * @var array */ - protected $userAgent = array(); + protected $userAgent = []; /** * @var Common\Authentication @@ -48,12 +48,12 @@ class HttpClient /** * @var array */ - private $headers = array(); + private $headers = []; /** * @var array */ - private $httpOptions = array(); + private $httpOptions = []; /** * @param string $endpoint @@ -61,7 +61,7 @@ class HttpClient * @param int $connectionTimeout >= 0 * @param array $headers */ - public function __construct($endpoint, $timeout = 10, $connectionTimeout = 2, $headers = array()) + public function __construct($endpoint, $timeout = 10, $connectionTimeout = 2, $headers = []) { $this->endpoint = $endpoint; @@ -165,13 +165,13 @@ public function performHttpRequest($method, $resourceName, $query = null, $body throw new Exceptions\AuthenticateException('Can not perform API Request without Authentication'); } - $headers = array ( + $headers = [ 'User-agent: ' . implode(' ', $this->userAgent), 'Accept: application/json', 'Content-Type: application/json', 'Accept-Charset: utf-8', sprintf('Authorization: AccessKey %s', $this->Authentication->accessKey) - ); + ]; $headers = array_merge($headers, $this->headers); @@ -220,11 +220,11 @@ public function performHttpRequest($method, $resourceName, $query = null, $body // Split the header and body $parts = explode("\r\n\r\n", $response, 3); $isThreePartResponse = (strpos($parts[0], "\n") === false && strpos($parts[0], 'HTTP/1.') === 0); - list($responseHeader, $responseBody) = $isThreePartResponse ? array ($parts[1], $parts[2]) : array ($parts[0], $parts[1]); + list($responseHeader, $responseBody) = $isThreePartResponse ? [$parts[1], $parts[2]] : [$parts[0], $parts[1]]; curl_close($curl); - return array ($responseStatus, $responseHeader, $responseBody); + return [$responseStatus, $responseHeader, $responseBody]; } /** diff --git a/src/MessageBird/Common/ResponseError.php b/src/MessageBird/Common/ResponseError.php index ee8d9e19..a238e48b 100644 --- a/src/MessageBird/Common/ResponseError.php +++ b/src/MessageBird/Common/ResponseError.php @@ -26,7 +26,7 @@ class ResponseError const CHAT_API_AUTH_ERROR = 1001; - public $errors = array(); + public $errors = []; /** * Load the error data into an array. @@ -80,7 +80,7 @@ private function getExceptionMessage($error) */ public function getErrorString() { - $errorDescriptions = array(); + $errorDescriptions = []; foreach ($this->errors AS $error) { $errorDescriptions[] = $error->description; diff --git a/src/MessageBird/Objects/BaseList.php b/src/MessageBird/Objects/BaseList.php index b229a660..f9e78440 100644 --- a/src/MessageBird/Objects/BaseList.php +++ b/src/MessageBird/Objects/BaseList.php @@ -14,12 +14,12 @@ class BaseList extends Base public $offset; public $count; public $totalCount; - public $links = array ( + public $links = [ 'first' => null, 'previous' => null, 'next' => null, 'last' => null, - ); + ]; - public $items = array (); + public $items = []; } diff --git a/src/MessageBird/Objects/Chat/Channel.php b/src/MessageBird/Objects/Chat/Channel.php index f2f9f517..f7818b09 100644 --- a/src/MessageBird/Objects/Chat/Channel.php +++ b/src/MessageBird/Objects/Chat/Channel.php @@ -78,6 +78,6 @@ class Channel extends Base /** * @var array */ - protected $_links = array(); + protected $_links = []; } \ No newline at end of file diff --git a/src/MessageBird/Objects/Chat/Contact.php b/src/MessageBird/Objects/Chat/Contact.php index 675901d9..e2716d17 100644 --- a/src/MessageBird/Objects/Chat/Contact.php +++ b/src/MessageBird/Objects/Chat/Contact.php @@ -38,7 +38,7 @@ class Contact extends Base * * @var array */ - public $contactDetails = array(); + public $contactDetails = []; /** * Channel ID. diff --git a/src/MessageBird/Objects/Chat/Message.php b/src/MessageBird/Objects/Chat/Message.php index f77fde23..6920b821 100644 --- a/src/MessageBird/Objects/Chat/Message.php +++ b/src/MessageBird/Objects/Chat/Message.php @@ -73,7 +73,7 @@ class Message extends Base /** * @var array */ - protected $_links = array(); + protected $_links = []; public function getId() diff --git a/src/MessageBird/Objects/Chat/Platform.php b/src/MessageBird/Objects/Chat/Platform.php index 3713cc49..dabf07ad 100644 --- a/src/MessageBird/Objects/Chat/Platform.php +++ b/src/MessageBird/Objects/Chat/Platform.php @@ -32,7 +32,7 @@ class Platform extends Base * * @var array */ - protected $contactTemplate = array(); + protected $contactTemplate = []; /** * The name of the channel details parameter that uniquely identifies a channel on this platform. diff --git a/src/MessageBird/Objects/Contact.php b/src/MessageBird/Objects/Contact.php index 281fd8b2..c151eede 100644 --- a/src/MessageBird/Objects/Contact.php +++ b/src/MessageBird/Objects/Contact.php @@ -51,7 +51,7 @@ class Contact extends Base * * @var array */ - protected $customDetails = array(); + protected $customDetails = []; /** * @var string @@ -78,14 +78,14 @@ class Contact extends Base * * @var array */ - protected $groups = array(); + protected $groups = []; /** * The hash with messages sent to contact. * * @var array */ - protected $messages = array(); + protected $messages = []; /** * The date and time of the creation of the contact in RFC3339 format (Y-m-d\TH:i:sP) diff --git a/src/MessageBird/Objects/Conversation/Content.php b/src/MessageBird/Objects/Conversation/Content.php index a9ebc17e..a4f21134 100644 --- a/src/MessageBird/Objects/Conversation/Content.php +++ b/src/MessageBird/Objects/Conversation/Content.php @@ -76,10 +76,10 @@ public function loadFromArray($object) private function loadLocationIfNeeded() { if (!empty($this->location->latitude) && !empty($this->location->longitude)) { - $this->location = array( + $this->location = [ 'latitude' => $this->location->latitude, 'longitude' => $this->location->longitude, - ); + ]; } } @@ -89,19 +89,19 @@ private function loadLocationIfNeeded() private function loadMediaIfNeeded() { if (!empty($this->audio->url)) { - $this->audio = array('url' => $this->audio->url); + $this->audio = ['url' => $this->audio->url]; } if (!empty($this->file->url)) { - $this->file = array('url' => $this->file->url); + $this->file = ['url' => $this->file->url]; } if (!empty($this->image->url)) { - $this->image = array('url' => $this->image->url); + $this->image = ['url' => $this->image->url]; } if (!empty($this->video->url)) { - $this->video = array('url' => $this->video->url); + $this->video = ['url' => $this->video->url]; } } @@ -110,7 +110,7 @@ private function loadMediaIfNeeded() */ public function jsonSerialize() { - $json = array(); + $json = []; foreach (get_object_vars($this) as $key => $value) { if (!empty($value)) { diff --git a/src/MessageBird/Objects/Conversation/Conversation.php b/src/MessageBird/Objects/Conversation/Conversation.php index d01f3f6e..6a2cd342 100644 --- a/src/MessageBird/Objects/Conversation/Conversation.php +++ b/src/MessageBird/Objects/Conversation/Conversation.php @@ -112,7 +112,7 @@ public function loadFromArray($object) } if (!empty($this->channels)) { - $channels = array(); + $channels = []; foreach ($this->channels as $channel) { $newChannel = new Channel(); diff --git a/src/MessageBird/Objects/Conversation/Message.php b/src/MessageBird/Objects/Conversation/Message.php index b687335e..9de3930d 100644 --- a/src/MessageBird/Objects/Conversation/Message.php +++ b/src/MessageBird/Objects/Conversation/Message.php @@ -116,7 +116,7 @@ public function loadFromArray($object) */ public function jsonSerialize() { - $json = array(); + $json = []; foreach (get_object_vars($this) as $key => $value) { if (!empty($value)) { diff --git a/src/MessageBird/Objects/Conversation/SendMessage.php b/src/MessageBird/Objects/Conversation/SendMessage.php index 8a4d2f37..2679a1b6 100644 --- a/src/MessageBird/Objects/Conversation/SendMessage.php +++ b/src/MessageBird/Objects/Conversation/SendMessage.php @@ -74,7 +74,7 @@ class SendMessage extends Base implements JsonSerializable */ public function jsonSerialize() { - $json = array(); + $json = []; foreach (get_object_vars($this) as $key => $value) { if (!empty($value)) { diff --git a/src/MessageBird/Objects/Conversation/SendMessageResult.php b/src/MessageBird/Objects/Conversation/SendMessageResult.php index 27f35baf..e48b71ba 100644 --- a/src/MessageBird/Objects/Conversation/SendMessageResult.php +++ b/src/MessageBird/Objects/Conversation/SendMessageResult.php @@ -22,7 +22,7 @@ class SendMessageResult extends Base implements JsonSerializable */ public function jsonSerialize() { - $json = array(); + $json = []; foreach (get_object_vars($this) as $key => $value) { if (!empty($value)) { diff --git a/src/MessageBird/Objects/Conversation/Webhook.php b/src/MessageBird/Objects/Conversation/Webhook.php index 03486bf3..7271592c 100644 --- a/src/MessageBird/Objects/Conversation/Webhook.php +++ b/src/MessageBird/Objects/Conversation/Webhook.php @@ -77,7 +77,7 @@ class Webhook extends Base implements JsonSerializable */ public function jsonSerialize() { - $json = array(); + $json = []; foreach (get_object_vars($this) as $key => $value) { if (!empty($value)) { diff --git a/src/MessageBird/Objects/Group.php b/src/MessageBird/Objects/Group.php index 468ca356..f702de6a 100644 --- a/src/MessageBird/Objects/Group.php +++ b/src/MessageBird/Objects/Group.php @@ -37,7 +37,7 @@ class Group extends Base * * @var array */ - protected $contacts = array (); + protected $contacts = []; /** * The date and time of the creation of the group in RFC3339 format (Y-m-d\TH:i:sP) diff --git a/src/MessageBird/Objects/Hlr.php b/src/MessageBird/Objects/Hlr.php index 9338d030..e7b21a7a 100644 --- a/src/MessageBird/Objects/Hlr.php +++ b/src/MessageBird/Objects/Hlr.php @@ -49,7 +49,7 @@ class Hlr extends Base * * @var array */ - public $details = array(); + public $details = []; /** * A client reference. Here you can put your own reference, diff --git a/src/MessageBird/Objects/Message.php b/src/MessageBird/Objects/Message.php index 8c92e2e3..a3e21a3c 100644 --- a/src/MessageBird/Objects/Message.php +++ b/src/MessageBird/Objects/Message.php @@ -95,7 +95,7 @@ class Message extends Base * * @var array */ - public $typeDetails = array (); + public $typeDetails = []; /** * The datacoding used, can be plain or unicode @@ -129,7 +129,7 @@ class Message extends Base * * @var array */ - public $recipients = array (); + public $recipients = []; /** * The URL to send status delivery reports for the message to diff --git a/src/MessageBird/Objects/MmsMessage.php b/src/MessageBird/Objects/MmsMessage.php index 98fb0c0b..c0068a09 100644 --- a/src/MessageBird/Objects/MmsMessage.php +++ b/src/MessageBird/Objects/MmsMessage.php @@ -47,7 +47,7 @@ class MmsMessage extends Base { * * @var array */ - public $recipients = array(); + public $recipients = []; /** * The subject of MMS the message. @@ -69,7 +69,7 @@ class MmsMessage extends Base { * * @var array */ - public $mediaUrls = array(); + public $mediaUrls = []; /** * A client reference. diff --git a/src/MessageBird/Objects/SignedRequest.php b/src/MessageBird/Objects/SignedRequest.php index 196edb34..fe1b8fb2 100644 --- a/src/MessageBird/Objects/SignedRequest.php +++ b/src/MessageBird/Objects/SignedRequest.php @@ -32,7 +32,7 @@ class SignedRequest extends Base * * @var array */ - public $queryParameters = array(); + public $queryParameters = []; /** * The signature passed in the MessageBird-Signature header of the request. @@ -75,7 +75,7 @@ public static function createFromGlobals() public static function create($query, $signature, $requestTimestamp, $body) { if (is_string($query)) { - $queryParameters = array(); + $queryParameters = []; parse_str($query, $queryParameters); } else { $queryParameters = $query; diff --git a/src/MessageBird/Objects/Voice/BaseList.php b/src/MessageBird/Objects/Voice/BaseList.php index 79cacd95..4be90765 100644 --- a/src/MessageBird/Objects/Voice/BaseList.php +++ b/src/MessageBird/Objects/Voice/BaseList.php @@ -17,5 +17,5 @@ class BaseList extends Base public $currentPage; public $perPage; - public $items = array (); + public $items = []; } diff --git a/src/MessageBird/Objects/VoiceMessage.php b/src/MessageBird/Objects/VoiceMessage.php index bb72c7ff..a45ede49 100644 --- a/src/MessageBird/Objects/VoiceMessage.php +++ b/src/MessageBird/Objects/VoiceMessage.php @@ -107,7 +107,7 @@ class VoiceMessage extends Base * * @var array */ - public $recipients = array (); + public $recipients = []; /** * The URL to send status delivery reports for the voice message to diff --git a/src/MessageBird/RequestValidator.php b/src/MessageBird/RequestValidator.php index 2b287d3e..979a84d0 100644 --- a/src/MessageBird/RequestValidator.php +++ b/src/MessageBird/RequestValidator.php @@ -49,7 +49,7 @@ public function verify(SignedRequest $request) private function buildPayloadFromRequest(SignedRequest $request) { - $parts = array(); + $parts = []; // Add request timestamp $parts[] = $request->requestTimestamp; diff --git a/src/MessageBird/Resources/Base.php b/src/MessageBird/Resources/Base.php index 708569e8..35ad2ff6 100644 --- a/src/MessageBird/Resources/Base.php +++ b/src/MessageBird/Resources/Base.php @@ -84,7 +84,7 @@ public function create($object, $query = null) return $this->processRequest($body); } - public function getList($parameters = array ()) + public function getList($parameters = []) { list($status, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_GET, $this->resourceName, $parameters); @@ -181,7 +181,7 @@ public function processRequest($body) public function update($object, $id) { $objVars = get_object_vars($object); - $body = array(); + $body = []; foreach ($objVars as $key => $value) { if (null !== $value) { $body[$key] = $value; diff --git a/src/MessageBird/Resources/Contacts.php b/src/MessageBird/Resources/Contacts.php index 0b2ade0e..b8d3fe7e 100644 --- a/src/MessageBird/Resources/Contacts.php +++ b/src/MessageBird/Resources/Contacts.php @@ -36,7 +36,7 @@ public function __construct(Common\HttpClient $HttpClient) public function update($object, $id) { $objVars = get_object_vars($object); - $body = array(); + $body = []; foreach ($objVars as $key => $value) { if (null !== $value) { $body[$key] = $value; @@ -56,7 +56,7 @@ public function update($object, $id) * @param array|null $parameters * @return $this ->Object */ - public function getMessages($id, $parameters = array()) + public function getMessages($id, $parameters = []) { if (is_null($id)) { throw new InvalidArgumentException('No contact id provided.'); @@ -72,7 +72,7 @@ public function getMessages($id, $parameters = array()) * @param array|null $parameters * @return $this ->Object */ - public function getGroups($id, $parameters = array()) + public function getGroups($id, $parameters = []) { if (is_null($id)) { throw new InvalidArgumentException('No contact id provided.'); diff --git a/src/MessageBird/Resources/Conversation/Conversations.php b/src/MessageBird/Resources/Conversation/Conversations.php index 950fb926..7ada858e 100644 --- a/src/MessageBird/Resources/Conversation/Conversations.php +++ b/src/MessageBird/Resources/Conversation/Conversations.php @@ -67,7 +67,7 @@ private function getStartUrl() */ public function create($contactId, $query = null) { - $body = json_encode(array('contactId' => $contactId)); + $body = json_encode(['contactId' => $contactId]); list(, , $body) = $this->HttpClient->performHttpRequest( HttpClient::REQUEST_POST, @@ -90,7 +90,7 @@ public function create($contactId, $query = null) public function update($object, $id) { $objVars = get_object_vars($object); - $body = array(); + $body = []; foreach ($objVars as $key => $value) { if (null !== $value) { diff --git a/src/MessageBird/Resources/Conversation/Messages.php b/src/MessageBird/Resources/Conversation/Messages.php index 2e836209..0ba2617a 100644 --- a/src/MessageBird/Resources/Conversation/Messages.php +++ b/src/MessageBird/Resources/Conversation/Messages.php @@ -92,7 +92,7 @@ public function create($conversationId, $object, $query = null) * @param string $conversationId * @param string[] $parameters */ - public function getList($conversationId, $parameters = array()) + public function getList($conversationId, $parameters = []) { list($status, , $body) = $this->httpClient->performHttpRequest( HttpClient::REQUEST_GET, @@ -124,7 +124,7 @@ public function getList($conversationId, $parameters = array()) return $this->processRequest($body); } - public function read($messageId, $parameters = array()) { + public function read($messageId, $parameters = []) { list($status, , $body) = $this->httpClient->performHttpRequest( HttpClient::REQUEST_GET, sprintf(self::MESSAGE_RESOURCE_NAME, $messageId), diff --git a/src/MessageBird/Resources/Groups.php b/src/MessageBird/Resources/Groups.php index 00a8fa25..fb75a7a7 100644 --- a/src/MessageBird/Resources/Groups.php +++ b/src/MessageBird/Resources/Groups.php @@ -40,7 +40,7 @@ public function __construct(Common\HttpClient $HttpClient) public function update($object, $id) { $objVars = get_object_vars($object); - $body = array(); + $body = []; foreach ($objVars as $key => $value) { if (null !== $value) { $body[$key] = $value; @@ -67,7 +67,7 @@ public function update($object, $id) * * @return mixed */ - public function getContacts($id = null, $parameters = array()) + public function getContacts($id = null, $parameters = []) { if (is_null($id)) { throw new InvalidArgumentException('No group id provided.'); diff --git a/src/MessageBird/Resources/Lookup.php b/src/MessageBird/Resources/Lookup.php index f104a311..f2f95239 100644 --- a/src/MessageBird/Resources/Lookup.php +++ b/src/MessageBird/Resources/Lookup.php @@ -42,7 +42,7 @@ public function read($phoneNumber = null, $countryCode = null) } $query = null; if ($countryCode !== null) { - $query = array("countryCode" => $countryCode); + $query = ["countryCode" => $countryCode]; } $ResourceName = $this->resourceName . '/' . $phoneNumber; list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_GET, $ResourceName, $query); diff --git a/src/MessageBird/Resources/LookupHlr.php b/src/MessageBird/Resources/LookupHlr.php index 059f0d37..9c682c0e 100644 --- a/src/MessageBird/Resources/LookupHlr.php +++ b/src/MessageBird/Resources/LookupHlr.php @@ -43,7 +43,7 @@ public function create($hlr, $countryCode = null) $query = null; if ($countryCode !== null) { - $query = array("countryCode" => $countryCode); + $query = ["countryCode" => $countryCode]; } $ResourceName = $this->resourceName . '/' . ($hlr->msisdn) . '/hlr' ; list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_POST, $ResourceName, $query, json_encode($hlr)); @@ -68,7 +68,7 @@ public function read($phoneNumber = null, $countryCode = null) $query = null; if ($countryCode !== null) { - $query = array("countryCode" => $countryCode); + $query = ["countryCode" => $countryCode]; } $ResourceName = $this->resourceName . '/' . $phoneNumber . '/hlr' ; list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_GET, $ResourceName, $query, null); diff --git a/src/MessageBird/Resources/Verify.php b/src/MessageBird/Resources/Verify.php index 1e271f17..a4bcb56e 100644 --- a/src/MessageBird/Resources/Verify.php +++ b/src/MessageBird/Resources/Verify.php @@ -37,7 +37,7 @@ public function __construct(Common\HttpClient $HttpClient) public function verify($id, $token) { $ResourceName = $this->resourceName . (($id) ? '/' . $id : null); - list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_GET, $ResourceName, array('token' => $token)); + list(, , $body) = $this->HttpClient->performHttpRequest(Common\HttpClient::REQUEST_GET, $ResourceName, ['token' => $token]); return $this->processRequest($body); } } diff --git a/src/MessageBird/Resources/Voice/Base.php b/src/MessageBird/Resources/Voice/Base.php index f092a865..8d6f6109 100644 --- a/src/MessageBird/Resources/Voice/Base.php +++ b/src/MessageBird/Resources/Voice/Base.php @@ -13,7 +13,7 @@ */ class Base extends \MessageBird\Resources\Base { - public function getList($parameters = array()) + public function getList($parameters = []) { list($status, , $body) = $this->HttpClient->performHttpRequest( Common\HttpClient::REQUEST_GET, diff --git a/src/MessageBird/Resources/Voice/Legs.php b/src/MessageBird/Resources/Voice/Legs.php index e7eb91dc..8130e9ce 100644 --- a/src/MessageBird/Resources/Voice/Legs.php +++ b/src/MessageBird/Resources/Voice/Legs.php @@ -54,7 +54,7 @@ public function getObject() * * @return Objects\Voice\Leg */ - public function getList($callId, $parameters = array()) + public function getList($callId, $parameters = []) { list($status, , $body) = $this->HttpClient->performHttpRequest( Common\HttpClient::REQUEST_GET, diff --git a/src/MessageBird/Resources/Voice/Recordings.php b/src/MessageBird/Resources/Voice/Recordings.php index cf155241..bdbe8fe7 100644 --- a/src/MessageBird/Resources/Voice/Recordings.php +++ b/src/MessageBird/Resources/Voice/Recordings.php @@ -55,7 +55,7 @@ public function getObject() * * @return Objects\Voice\Recording */ - public function getList($callId, $legId, $parameters = array()) + public function getList($callId, $legId, $parameters = []) { list($status, , $body) = $this->HttpClient->performHttpRequest( Common\HttpClient::REQUEST_GET, diff --git a/src/MessageBird/Resources/Voice/Transcriptions.php b/src/MessageBird/Resources/Voice/Transcriptions.php index d49a4bf3..5bcaa4d3 100644 --- a/src/MessageBird/Resources/Voice/Transcriptions.php +++ b/src/MessageBird/Resources/Voice/Transcriptions.php @@ -72,7 +72,7 @@ public function create($callId, $legId, $recordingId) * * @return Objects\Voice\Transcription */ - public function getList($callId, $legId, $recordingId, $parameters = array()) + public function getList($callId, $legId, $recordingId, $parameters = []) { list($status, , $body) = $this->HttpClient->performHttpRequest( Common\HttpClient::REQUEST_GET, diff --git a/tests/integration/BaseTest.php b/tests/integration/BaseTest.php index 4e51cfce..03840ba6 100644 --- a/tests/integration/BaseTest.php +++ b/tests/integration/BaseTest.php @@ -12,7 +12,7 @@ class BaseTest extends TestCase protected function setUp() { - $this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(array("fake.messagebird.dev"))->getMock(); + $this->mockClient = $this->getMockBuilder("\MessageBird\Common\HttpClient")->setConstructorArgs(["fake.messagebird.dev"])->getMock(); $this->client = new \MessageBird\Client('YOUR_ACCESS_KEY', $this->mockClient); } diff --git a/tests/integration/HttpClientTest.php b/tests/integration/HttpClientTest.php index 1d93de30..3e6a262f 100644 --- a/tests/integration/HttpClientTest.php +++ b/tests/integration/HttpClientTest.php @@ -12,7 +12,7 @@ public function testHttpClient() $url = $client->getRequestUrl('a', null); $this->assertSame(Client::ENDPOINT.'/a', $url); - $url = $client->getRequestUrl('a', array('b' => 1)); + $url = $client->getRequestUrl('a', ['b' => 1]); $this->assertSame(Client::ENDPOINT.'/a?b=1', $url); } diff --git a/tests/integration/chat/ChatTest.php b/tests/integration/chat/ChatTest.php index 219350e5..c4512385 100644 --- a/tests/integration/chat/ChatTest.php +++ b/tests/integration/chat/ChatTest.php @@ -14,7 +14,7 @@ public function testCreateChatMessage() $ChatMessage->payload = 'This is a test message to test the Chat API'; $ChatMessage->type = 'text'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560"}')); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560"}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"type":"text","payload":"This is a test message to test the Chat API","contactId":"9d754dac577e3ff103cdf4n29856560"}'); $this->client->chatMessages->create($ChatMessage); } @@ -22,8 +22,8 @@ public function testCreateChatMessage() public function testListChatMessage() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); - $ChatMessageList = $this->client->chatMessages->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', ['offset' => 100, 'limit' => 30], null); + $ChatMessageList = $this->client->chatMessages->getList( ['offset' => 100, 'limit' => 30]); } public function testReadChatMessage() @@ -41,12 +41,12 @@ public function testCreateChatChannel() $ChatChannel->platformId = 'e84f332c5649a5f911e569n69330697'; $ChatChannel->channelDetails = - array( + [ 'botName' => 'testBot', 'token' => '1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA' - ); + ]; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null}')); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'channels', null, '{"name":"Test Channel Telegram","platformId":"e84f332c5649a5f911e569n69330697","channelDetails":{"botName":"testBot","token":"1234566778:A34JT44Yr4amk234352et5hvRnHeAEHA"},"callbackUrl":null}'); $this->client->chatChannels->create($ChatChannel); } @@ -54,8 +54,8 @@ public function testCreateChatChannel() public function testListChatChannels() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', array ('offset' => 100, 'limit' => 30), null); - $ChannelList = $this->client->chatChannels->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'channels', ['offset' => 100, 'limit' => 30], null); + $ChannelList = $this->client->chatChannels->getList( ['offset' => 100, 'limit' => 30]); } public function testReadChatChannel() @@ -78,7 +78,7 @@ public function testUpdateChatChannel() $ChatChannel->name = '9d2345ac577e4f103cd3d4529856560'; $ChatChannel->callbackUrl = 'http://testurl.dev'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"name":"9d2345ac577e4f103cd3d4529856560","callbackUrl":"http:\/\/testurl.dev"}')); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{"name":"9d2345ac577e4f103cd3d4529856560","callbackUrl":"http:\/\/testurl.dev"}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("PUT", 'channels/234agfgADFH2974gaADFH3hudf9h', null, '{"name":"9d2345ac577e4f103cd3d4529856560","callbackUrl":"http:\/\/testurl.dev"}'); $this->client->chatChannels->update($ChatChannel,'234agfgADFH2974gaADFH3hudf9h'); } @@ -86,8 +86,8 @@ public function testUpdateChatChannel() public function testListChatPlatforms() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', array ('offset' => 100, 'limit' => 30), null); - $ChannelList = $this->client->chatPlatforms->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'platforms', ['offset' => 100, 'limit' => 30], null); + $ChannelList = $this->client->chatPlatforms->getList( ['offset' => 100, 'limit' => 30]); } public function testReadChatPlatform() @@ -100,8 +100,8 @@ public function testReadChatPlatform() public function testListChatContacts() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); - $ContactList = $this->client->chatContacts->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', ['offset' => 100, 'limit' => 30], null); + $ContactList = $this->client->chatContacts->getList( ['offset' => 100, 'limit' => 30]); } public function testReadChatContact() diff --git a/tests/integration/contacts/ContactTest.php b/tests/integration/contacts/ContactTest.php index f3adde86..ff7e56e0 100644 --- a/tests/integration/contacts/ContactTest.php +++ b/tests/integration/contacts/ContactTest.php @@ -19,7 +19,7 @@ public function testCreateContact() $Contact->custom4 = "Customfield4"; - $this->mockClient->expects($this->once())->method('performHttpRequest')->willReturn(array(200, '', '{ + $this->mockClient->expects($this->once())->method('performHttpRequest')->willReturn([200, '', '{ "id": "61afc0531573b08ddbe36e1c85602827", "href": "https://rest.messagebird.com/contacts/61afc0531573b08ddbe36e1c85602827", "msisdn": 31612345678, @@ -41,15 +41,15 @@ public function testCreateContact() }, "createdDatetime": "2016-04-29T09:42:26+00:00", "updatedDatetime": "2016-04-29T09:42:26+00:00" - }')); + }']); $this->client->contacts->create($Contact); } public function testListContacts() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', array ('offset' => 100, 'limit' => 30), null); - $this->client->contacts->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'contacts', ['offset' => 100, 'limit' => 30], null); + $this->client->contacts->getList( ['offset' => 100, 'limit' => 30]); } public function testViewContact() @@ -72,11 +72,11 @@ public function testContactGetGroups() ->with( $this->equalTo(MessageBird\Common\HttpClient::REQUEST_GET), $this->equalTo('contacts/contact_id/groups'), $this->anything(), $this->anything() ) - ->willReturn(array( + ->willReturn([ 200, '', '{"offset":0,"limit":20,"count":1,"totalCount":1,"links":{"first":"","previous":null,"next":null,"last":""},"items":[{"id":"contact_id","href":"","name":"GroupName","contacts":{"totalCount":1,"href":""},"createdDatetime":"","updatedDatetime":""}]}' - )); + ]); $ResultingGroupList = $this->client->contacts->getGroups("contact_id"); @@ -85,25 +85,25 @@ public function testContactGetGroups() $GroupList->offset = 0; $GroupList->count = 1; $GroupList->totalCount = 1; - $GroupList->links = (object) array( + $GroupList->links = (object) [ 'first' => '', 'previous' => null, 'next' => null, 'last' => '' - ); - $GroupList->items = array( - (object) array( + ]; + $GroupList->items = [ + (object) [ 'id' => 'contact_id', 'href' => '', 'name' => 'GroupName', - 'contacts' => (object) array( + 'contacts' => (object) [ 'totalCount' => 1, 'href' => '' - ), + ], 'createdDatetime' => '', 'updatedDatetime' => '' - ) - ); + ] + ]; $this->assertEquals($GroupList, $ResultingGroupList); } @@ -114,11 +114,11 @@ public function testContactGetMessages() ->with( $this->equalTo(MessageBird\Common\HttpClient::REQUEST_GET), $this->equalTo('contacts/contact_id/messages'), $this->anything(), $this->anything() ) - ->willReturn(array( + ->willReturn([ 200, '', '{"offset":0,"limit":20,"count":1,"totalCount":1,"links":{"first":"","previous":null,"next":null,"last":""},"items":[{"id":"contact_id","href":"","direction":"mt","type":"sms","originator":"MsgBird","body":"MessageBody","reference":null,"validity":null,"gateway":0,"typeDetails":{},"datacoding":"plain","mclass":1,"scheduledDatetime":null,"createdDatetime":"","recipients":{"totalCount":1,"totalSentCount":1,"totalDeliveredCount":1,"totalDeliveryFailedCount":0,"items":[{"recipient":12345678912,"status":"delivered","statusDatetime":""}]}}]}' - )); + ]); $Messages = $this->client->contacts->getMessages("contact_id"); foreach($Messages->items as $Message) { diff --git a/tests/integration/conversation/ConversationContentTest.php b/tests/integration/conversation/ConversationContentTest.php index bcde5197..a8eb3b1f 100644 --- a/tests/integration/conversation/ConversationContentTest.php +++ b/tests/integration/conversation/ConversationContentTest.php @@ -26,7 +26,7 @@ private function messageFromJson($json) public function testAudioContent() { $content = new Content(); - $content->audio = array('url' => 'https://example.com/audio.mp3'); + $content->audio = ['url' => 'https://example.com/audio.mp3']; $message = new Message(); $message->content = $content; @@ -40,7 +40,7 @@ public function testAudioContent() public function testFileContent() { $content = new Content(); - $content->file = array('url' => 'https://example.com/file.pdf'); + $content->file = ['url' => 'https://example.com/file.pdf']; $message = new Message(); $message->content = $content; @@ -54,7 +54,7 @@ public function testFileContent() public function testImageContent() { $content = new Content(); - $content->image = array('url' => 'https://example.com/image.png'); + $content->image = ['url' => 'https://example.com/image.png']; $message = new Message(); $message->content = $content; @@ -68,10 +68,10 @@ public function testImageContent() public function testLocationContent() { $content = new Content(); - $content->location = array( + $content->location = [ 'latitude' => '37.778326', 'longitude' => '-122.394648', - ); + ]; $message = new Message(); $message->content = $content; @@ -99,7 +99,7 @@ public function testTextContent() public function testVideoContent() { $content = new Content(); - $content->video = array('url' => 'https://example.com/video.mp4'); + $content->video = ['url' => 'https://example.com/video.mp4']; $message = new Message(); $message->content = $content; diff --git a/tests/integration/conversation/ConversationMessageTest.php b/tests/integration/conversation/ConversationMessageTest.php index 87111a53..3c342c17 100644 --- a/tests/integration/conversation/ConversationMessageTest.php +++ b/tests/integration/conversation/ConversationMessageTest.php @@ -58,12 +58,12 @@ public function testCreateImage() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations/some-conversation-id/messages', null, '{"channelId":"abcd1234","type":"image","content":{"image":{"url":"https:\/\/developers.messagebird.com\/assets\/images\/glyph.svg"}}}') - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $content = new Content(); - $content->image = array( + $content->image = [ 'url' => 'https://developers.messagebird.com/assets/images/glyph.svg' - ); + ]; $message = new Message(); $message->channelId = 'abcd1234'; @@ -78,13 +78,13 @@ public function testCreateLocation() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations/some-contact-id/messages', null, '{"channelId":"abcd1234","type":"location","content":{"location":{"latitude":"52.379112","longitude":"4.900384"}}}') - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $content = new Content(); - $content->location = array( + $content->location = [ 'latitude' => '52.379112', 'longitude' => '4.900384' - ); + ]; $message = new Message(); $message->channelId = 'abcd1234'; @@ -99,7 +99,7 @@ public function testCreateText() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations/some-other-contact-id/messages', null, '{"channelId":"abcd1234","type":"text","content":{"text":"Hello world"}}') - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $content = new Content(); $content->text = 'Hello world'; @@ -117,7 +117,7 @@ public function testCreateWithoutChannel() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations/genid/messages', null, '{"type":"text","content":{"text":"Hello world"}}') - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $content = new Content(); $content->text = 'Hello world'; @@ -133,8 +133,8 @@ public function testListPagination() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'conversations/genid/messages', array(), null) - ->willReturn(array(200, '', self::LIST_RESPONSE)); + ->with('GET', 'conversations/genid/messages', [], null) + ->willReturn([200, '', self::LIST_RESPONSE]); $messages = $this->client->conversationMessages->getList('genid'); @@ -148,15 +148,15 @@ public function testListObject() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'conversations/genid/messages', array(), null) - ->willReturn(array(200, '', self::LIST_RESPONSE)); + ->with('GET', 'conversations/genid/messages', [], null) + ->willReturn([200, '', self::LIST_RESPONSE]); $message = $this->client->conversationMessages->getList('genid')->items[0]; $expectedContent = new Content(); - $expectedContent->video = array( + $expectedContent->video = [ 'url' => 'https://developers.messagebird.com/assets/videos/foo.mp4' - ); + ]; $expectedMessage = new Message(); $expectedMessage->id = 'genid'; @@ -175,16 +175,16 @@ public function testReadMessage() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'messages/message-id', array(), null) - ->willReturn(array(200, '', self::READ_RESPONSE)); + ->with('GET', 'messages/message-id', [], null) + ->willReturn([200, '', self::READ_RESPONSE]); $message = $this->client->conversationMessages->read('message-id'); $expectedContent = new Content(); - $expectedContent->video = array( + $expectedContent->video = [ 'url' => 'https://developers.messagebird.com/assets/videos/foo.mp4' - ); + ]; $expectedMessage = new Message(); $expectedMessage->id = 'genid'; $expectedMessage->channelId = 'chid'; diff --git a/tests/integration/conversation/ConversationTest.php b/tests/integration/conversation/ConversationTest.php index 94938dd8..6f808902 100644 --- a/tests/integration/conversation/ConversationTest.php +++ b/tests/integration/conversation/ConversationTest.php @@ -106,13 +106,13 @@ public function testStart() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations/start', null, self::START_REQUEST) - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $content = new Content(); - $content->location = array( + $content->location = [ 'latitude' => '37.778326', 'longitude' => '-122.394648', - ); + ]; $message = new Message(); $message->channelId = 'channel-id'; @@ -131,7 +131,7 @@ public function testCreate() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'conversations', null, self::CREATE_REQUEST) - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $this->client->conversations->create('some-contact-id'); } @@ -140,15 +140,15 @@ public function testList() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'conversations', array(), null) - ->willReturn(array(200, '', self::LIST_RESPONSE)); + ->with('GET', 'conversations', [], null) + ->willReturn([200, '', self::LIST_RESPONSE]); $list = new BaseList(); $list->limit = 10; $list->offset = 0; $list->count = 1; $list->totalCount = 1; - $list->items = array($this->getConversation()); + $list->items = [$this->getConversation()]; $this->assertEquals( $list, @@ -161,7 +161,7 @@ public function testRead() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('GET', 'conversations/conversation-id', null, null) - ->willReturn(array(200, '', self::READ_RESPONSE)); + ->willReturn([200, '', self::READ_RESPONSE]); $this->assertEquals( $this->getConversation(), @@ -174,10 +174,10 @@ public function testUpdate() $this->mockClient ->expects($this->exactly(2))->method('performHttpRequest') ->withConsecutive( - array('PATCH', 'conversations/conversation-id', null, '{"status":"archived"}'), - array('PATCH', 'conversations/conversation-id', null, '{"status":"active"}') + ['PATCH', 'conversations/conversation-id', null, '{"status":"archived"}'], + ['PATCH', 'conversations/conversation-id', null, '{"status":"active"}'] ) - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $conversation = new Conversation(); @@ -201,9 +201,9 @@ private function getConversation() $contact->msisdn = '31612345678'; $contact->firstName = 'Foo'; $contact->lastName = 'Bar'; - $contact->customDetails = array( + $contact->customDetails = [ 'custom1' => 'Baz', - ); + ]; $contact->createdDatetime = '2018-07-20T12:13:41+00:00'; $contact->updatedDatetime = '2018-07-20T12:13:51+00:00'; @@ -221,7 +221,7 @@ private function getConversation() $conversation = new Conversation(); $conversation->contact = $contact; - $conversation->channels = array($channel); + $conversation->channels = [$channel]; $conversation->id = 'conversation-id'; $conversation->href = 'https://conversations.messagebird.com/v1/conversations/conversation-id'; $conversation->messages = $messages; diff --git a/tests/integration/conversation/ConversationWebhookTest.php b/tests/integration/conversation/ConversationWebhookTest.php index 3cae2ec5..6c6de7a9 100644 --- a/tests/integration/conversation/ConversationWebhookTest.php +++ b/tests/integration/conversation/ConversationWebhookTest.php @@ -49,7 +49,7 @@ public function testDelete() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('DELETE', 'webhooks/some-id', null, null) - ->willReturn(array(204, '', null)); + ->willReturn([204, '', null]); $this->client->conversationWebhooks->delete('some-id'); } @@ -59,15 +59,15 @@ public function testCreate() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('POST', 'webhooks', null, '{"channelId":"chid","events":["conversation.created","message.created"],"url":"https:\/\/messagebird.com\/webhook-receiver"}') - ->willReturn(array(200, '', '{}')); + ->willReturn([200, '', '{}']); $webhook = new Webhook(); $webhook->channelId = 'chid'; $webhook->url = 'https://messagebird.com/webhook-receiver'; - $webhook->events = array( + $webhook->events = [ Webhook::EVENT_CONVERSATION_CREATED, Webhook::EVENT_MESSAGE_CREATED, - ); + ]; $this->client->conversationWebhooks->create($webhook); } @@ -76,8 +76,8 @@ public function testListPagination() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'webhooks', array(), null) - ->willReturn(array(200, '', self::LIST_RESPONSE)); + ->with('GET', 'webhooks', [], null) + ->willReturn([200, '', self::LIST_RESPONSE]); $webhooks = $this->client->conversationWebhooks->getList(); @@ -91,13 +91,13 @@ public function testListObject() { $this->mockClient ->expects($this->once())->method('performHttpRequest') - ->with('GET', 'webhooks', array(), null) - ->willReturn(array(200, '', self::LIST_RESPONSE)); + ->with('GET', 'webhooks', [], null) + ->willReturn([200, '', self::LIST_RESPONSE]); $expectedWebhook = new Webhook(); $expectedWebhook->id = 'some-id'; $expectedWebhook->channelId = 'chid'; - $expectedWebhook->events = array('conversation.created', 'message.created'); + $expectedWebhook->events = ['conversation.created', 'message.created']; $expectedWebhook->url = 'https://example.com/webhook'; $expectedWebhook->createdDatetime = '2018-07-31T12:12:43Z'; @@ -112,17 +112,17 @@ public function testRead() $this->mockClient ->expects($this->once())->method('performHttpRequest') ->with('GET', 'webhooks/some-id', null, null) - ->willReturn(array(200, '', self::READ_RESPONSE)); + ->willReturn([200, '', self::READ_RESPONSE]); $webhook = new Webhook(); $webhook->id = 'some-id'; $webhook->href = 'https://conversations.messagebird.com/v1/webhooks/some-id'; $webhook->channelId = 'chid'; $webhook->url = 'https://messagebird.com/webhook-receiver'; - $webhook->events = array( + $webhook->events = [ Webhook::EVENT_CONVERSATION_UPDATED, Webhook::EVENT_MESSAGE_UPDATED, - ); + ]; $webhook->createdDatetime = '2018-07-20T12:13:41+00:00'; $webhook->updatedDatetime = '2018-07-20T12:13:51+00:00'; diff --git a/tests/integration/groups/GroupTest.php b/tests/integration/groups/GroupTest.php index 42a28beb..77a6ce72 100644 --- a/tests/integration/groups/GroupTest.php +++ b/tests/integration/groups/GroupTest.php @@ -13,7 +13,7 @@ public function testCreateGroup() $Group->name = "Home"; - $this->mockClient->expects($this->once())->method('performHttpRequest')->willReturn(array(200, '', '{ + $this->mockClient->expects($this->once())->method('performHttpRequest')->willReturn([200, '', '{ "id": "61afc0531573b08ddbe36e1c85602827", "href": "https://rest.messagebird.com/groups/61afc0531573b08ddbe36e1c85602827", "name": "Home", @@ -23,15 +23,15 @@ public function testCreateGroup() }, "createdDatetime": "2016-04-29T09:42:26+00:00", "updatedDatetime": "2016-04-29T09:42:26+00:00" - }')); + }']); $this->client->groups->create($Group); } public function testListGroups() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups', array ('offset' => 100, 'limit' => 30), null); - $this->client->groups->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'groups', ['offset' => 100, 'limit' => 30], null); + $this->client->groups->getList( ['offset' => 100, 'limit' => 30]); } public function testViewGroup() diff --git a/tests/integration/lookup/LookupTest.php b/tests/integration/lookup/LookupTest.php index 0533d1ee..7d6166dd 100644 --- a/tests/integration/lookup/LookupTest.php +++ b/tests/integration/lookup/LookupTest.php @@ -23,7 +23,7 @@ public function testReadLookupWithEmptyNumber() public function testReadLookupWithCountryCode() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $params = array("countryCode" => "NL"); + $params = ["countryCode" => "NL"]; $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678', $params, null); $this->client->lookup->read(612345678, $params["countryCode"]); } @@ -55,7 +55,7 @@ public function testCreateLookupHlrWithCountryCode() $Hlr->msisdn = 612345678; $Hlr->reference = "CoolReference"; - $params = array("countryCode" => "NL"); + $params = ["countryCode" => "NL"]; $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'lookup/'.$Hlr->msisdn.'/hlr', $params, json_encode($Hlr)); @@ -78,7 +78,7 @@ public function testReadLookupHlrWithEmptyNumber() public function testReadLookupHlrWithCountryCode() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $params = array("countryCode" => "NL"); + $params = ["countryCode" => "NL"]; $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'lookup/612345678/hlr', $params, null); $this->client->lookupHlr->read(612345678, $params["countryCode"]); } diff --git a/tests/integration/messages/MessagesTest.php b/tests/integration/messages/MessagesTest.php index 9e246bf1..429c6735 100644 --- a/tests/integration/messages/MessagesTest.php +++ b/tests/integration/messages/MessagesTest.php @@ -11,10 +11,10 @@ public function testCreateMessage() { $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; - $Message->recipients = array(31612345678); + $Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{ "id":"e8077d803532c0b5937c639b60216938", "href":"https://rest.messagebird.com/messages/e8077d803532c0b5937c639b60216938", "direction":"mt", @@ -45,7 +45,7 @@ public function testCreateMessage() ] }, "reportUrl":null - }')); + }']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"direction":"mt","type":"sms","originator":"MessageBird","body":"This is a test message.","reference":null,"validity":null,"gateway":null,"typeDetails":[],"datacoding":"plain","mclass":1,"scheduledDatetime":null,"recipients":[31612345678],"reportUrl":null}'); $this->client->messages->create($Message); } @@ -55,7 +55,7 @@ public function testPremiumSmsMessage() $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; - $Message->recipients = array(31612345678); + $Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; $Message->setPremiumSms(2002, 'mb', 1, 2); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"direction":"mt","type":"premium","originator":"MessageBird","body":"This is a test message.","reference":null,"validity":null,"gateway":null,"typeDetails":{"shortcode":2002,"keyword":"mb","tariff":1,"mid":2},"datacoding":"plain","mclass":1,"scheduledDatetime":null,"recipients":[31612345678],"reportUrl":null}'); @@ -67,7 +67,7 @@ public function testBinarySmsMessage() $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; - $Message->recipients = array(31612345678); + $Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; $Message->setBinarySms("HEADER", "test"); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'messages', null, '{"direction":"mt","type":"binary","originator":"MessageBird","body":"test","reference":null,"validity":null,"gateway":null,"typeDetails":{"udh":"HEADER"},"datacoding":"plain","mclass":1,"scheduledDatetime":null,"recipients":[31612345678],"reportUrl":null}'); @@ -80,7 +80,7 @@ public function testFlashSmsMessage() $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\Message(); $Message->originator = 'MessageBird'; - $Message->recipients = array(31612345678); + $Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; $Message->setBinarySms("HEADER", "test"); $Message->setFlash(true); @@ -92,8 +92,8 @@ public function testFlashSmsMessage() public function testListMessage() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', array ('offset' => 100, 'limit' => 30), null); - $this->client->messages->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'messages', ['offset' => 100, 'limit' => 30], null); + $this->client->messages->getList( ['offset' => 100, 'limit' => 30]); } public function testReadMessage() diff --git a/tests/integration/mms/MmsTest.php b/tests/integration/mms/MmsTest.php index 3482457a..1c7c2333 100644 --- a/tests/integration/mms/MmsTest.php +++ b/tests/integration/mms/MmsTest.php @@ -9,7 +9,7 @@ public function testCreateMmsFail() $this->mockClient->expects($this->once()) ->method('performHttpRequest') ->with('POST', 'mms', null, json_encode($MmsMessage)) - ->willReturn(array(422, '', '{"errors":[{"code":9,"description":"no (correct) recipients found","parameter":"recipients"}]}')); + ->willReturn([422, '', '{"errors":[{"code":9,"description":"no (correct) recipients found","parameter":"recipients"}]}']); $this->client->mmsMessages->create($MmsMessage); } @@ -22,7 +22,7 @@ public function testCreateMmsSuccess() $this->mockClient->expects($this->once()) ->method('performHttpRequest') ->with('POST', 'mms', null, json_encode($MmsMessage)) - ->willReturn(array(200, '', $this->generateMmsServerResponse($MmsMessage, $dummyMessageId))); + ->willReturn([200, '', $this->generateMmsServerResponse($MmsMessage, $dummyMessageId)]); $ResultMmsMessage = $this->client->mmsMessages->create($MmsMessage); @@ -35,8 +35,8 @@ public function testListMms() $this->mockClient->expects($this->once()) ->method('performHttpRequest') - ->with('GET', 'mms', array('offset' => '100', 'limit' => '30'), null) - ->willReturn(array(200, '', + ->with('GET', 'mms', ['offset' => '100', 'limit' => '30'], null) + ->willReturn([200, '', '{ "offset": 0, "limit": 20, "count": 1, "totalCount": 2, "links": { @@ -48,9 +48,9 @@ public function testListMms() "items": [ ' . $this->generateMmsServerResponse($dummyMessage, 'message_id') . ', ' . $this->generateMmsServerResponse($dummyMessage, 'message_id_2') . '] }' - )); + ]); - $ResultMessages = $this->client->mmsMessages->getList(array('offset' => 100, 'limit' => 30)); + $ResultMessages = $this->client->mmsMessages->getList(['offset' => 100, 'limit' => 30]); $this->assertAttributeEquals(0, 'offset', $ResultMessages); $this->assertAttributeEquals(1, 'count', $ResultMessages); @@ -69,8 +69,8 @@ public function testDeleteMms() ->method('performHttpRequest') ->with('DELETE', 'mms/message_id', null, null) ->will($this->onConsecutiveCalls( - array(204, '', ''), - array(404, '', '{"errors":[{"code":20,"description":"message not found","parameter":null}]}') + [204, '', ''], + [404, '', '{"errors":[{"code":20,"description":"message not found","parameter":null}]}'] )); $this->client->mmsMessages->delete('message_id'); @@ -88,8 +88,8 @@ public function testReadMms() ->method('performHttpRequest') ->with('GET', $this->logicalOr('mms/message_id', 'mms/unknown_message_id'), null, null) ->will($this->onConsecutiveCalls( - array('200', '', $this->generateMmsServerResponse($dummyMessage, 'message_id')), - array('404', '', '{"errors":[{"code":20,"description":"message not found","parameter":null}]}') + ['200', '', $this->generateMmsServerResponse($dummyMessage, 'message_id')], + ['404', '', '{"errors":[{"code":20,"description":"message not found","parameter":null}]}'] )); $ResultMmsMessage = $this->client->mmsMessages->read('message_id'); @@ -107,9 +107,9 @@ private function generateDummyMessage() $MmsMessage = new \MessageBird\Objects\MmsMessage(); $MmsMessage->originator = "MessageBird"; $MmsMessage->direction = 'ot'; - $MmsMessage->recipients = array(31621938645); + $MmsMessage->recipients = [31621938645]; $MmsMessage->body = 'Have you seen this logo?'; - $MmsMessage->mediaUrls = array('https://www.messagebird.com/assets/images/og/messagebird.gif'); + $MmsMessage->mediaUrls = ['https://www.messagebird.com/assets/images/og/messagebird.gif']; return $MmsMessage; } @@ -131,7 +131,7 @@ private function assertMessagesAreEqual(\MessageBird\Objects\MmsMessage $MmsMess $this->assertAttributeEquals($MmsMessage->reference, 'reference', $ResultMmsMessage); foreach($ResultMmsMessage->recipients->items as $item) { - $this->assertArraySubset(array($item->recipient), $MmsMessage->recipients); + $this->assertArraySubset([$item->recipient], $MmsMessage->recipients); } } diff --git a/tests/integration/numbers/AvailablePhoneNumbersTest.php b/tests/integration/numbers/AvailablePhoneNumbersTest.php index 9f64dc0d..545fae6e 100644 --- a/tests/integration/numbers/AvailablePhoneNumbersTest.php +++ b/tests/integration/numbers/AvailablePhoneNumbersTest.php @@ -10,7 +10,7 @@ protected function setUp() public function testListAvailablePhoneNumbers() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'available-phone-numbers/nl', array (), null); - $this->client->availablePhoneNumbers->getList("nl", array()); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'available-phone-numbers/nl', [], null); + $this->client->availablePhoneNumbers->getList("nl", []); } } diff --git a/tests/integration/numbers/PhoneNumbersTest.php b/tests/integration/numbers/PhoneNumbersTest.php index da95cdd1..701b05c7 100644 --- a/tests/integration/numbers/PhoneNumbersTest.php +++ b/tests/integration/numbers/PhoneNumbersTest.php @@ -17,16 +17,16 @@ public function testReadPhoneNumber() public function testListPhoneNumbers() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'phone-numbers', array (), null); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with('GET', 'phone-numbers', [], null); $this->client->phoneNumbers->getList(); } public function testUpdatePhoneNumber() { $Number = new \MessageBird\Objects\Number(); - $Number->tags = array('tag1'); + $Number->tags = ['tag1']; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{"tags":["tag1"]}')); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{"tags":["tag1"]}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with('PATCH', 'phone-numbers/31612345678', null, '{"tags":["tag1"]}'); $this->client->phoneNumbers->update($Number, '31612345678'); } @@ -40,14 +40,14 @@ public function testPurchasePhoneNumber() $NumberJSON = '{"number":"31612345678","countryCode":"NL","billingIntervalMonths":1}'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', "[$NumberJSON]")); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([201, '', "[$NumberJSON]"]); $this->mockClient->expects($this->once())->method('performHttpRequest')->with('POST', 'phone-numbers', null, $NumberJSON); $this->client->phoneNumbers->create($NumberPurchaseRequest); } public function testCancelPhoneNumber() { - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(204, '', '')); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([204, '', '']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with('DELETE', 'phone-numbers/31612345678', null, null); $this->client->phoneNumbers->delete('31612345678'); } diff --git a/tests/integration/verify/VerifyTest.php b/tests/integration/verify/VerifyTest.php index c796a968..008b45bc 100644 --- a/tests/integration/verify/VerifyTest.php +++ b/tests/integration/verify/VerifyTest.php @@ -26,7 +26,7 @@ public function testVerifyOtp() $Verify->recipient = 31612345678; $Verify->reference = 'Yoloswag3000'; - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'verify/onofao3f82f7u2fb2uf', array('token' => '123456')); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'verify/onofao3f82f7u2fb2uf', ['token' => '123456']); $this->client->verify->verify('onofao3f82f7u2fb2uf', 123456); } diff --git a/tests/integration/voice/VoiceTest.php b/tests/integration/voice/VoiceTest.php index 831e1105..51ef7ee2 100644 --- a/tests/integration/voice/VoiceTest.php +++ b/tests/integration/voice/VoiceTest.php @@ -14,11 +14,11 @@ protected function setUp() public function testListVoiceCall() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceCalls->getList(array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceCalls->getList(['offset' => 100, 'limit' => 30]); } public function testReadVoiceCall() @@ -33,16 +33,16 @@ public function testCreateVoiceCall() $voiceCall = new \MessageBird\Objects\Voice\Call(); $voiceCall->source = '31612354678'; $voiceCall->destination = '31611223344'; - $voiceCall->callFlow = array( + $voiceCall->callFlow = [ 'title' => 'Foobar', - 'steps' => array( - array( + 'steps' => [ + [ 'action' => 'hangup', - ), - ), - ); + ], + ], + ]; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([201, '', '{ "data": [ { "id": "21025ed1-cc1d-4554-ac05-043fa6c84e00", @@ -57,7 +57,7 @@ public function testCreateVoiceCall() "_links": { "self": "/calls/21025ed1-cc1d-4554-ac05-043fa6c84e00" } -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'calls', null, '{"source":"31612354678","destination":"31611223344","callFlow":{"title":"Foobar","steps":[{"action":"hangup"}]}}'); $this->client->voiceCalls->create($voiceCall); } @@ -65,11 +65,11 @@ public function testCreateVoiceCall() public function testListVoiceLegs() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar/legs', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foobar/legs', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceLegs->getList('foobar', array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceLegs->getList('foobar', ['offset' => 100, 'limit' => 30]); } public function testReadVoiceLeg() @@ -82,11 +82,11 @@ public function testReadVoiceLeg() public function testListVoiceRecordings() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceRecordings->getList('foo', 'bar', array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceRecordings->getList('foo', 'bar', ['offset' => 100, 'limit' => 30]); } public function testReadVoiceRecording() @@ -99,7 +99,7 @@ public function testReadVoiceRecording() public function testDeleteVoiceRecording() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(204, '', null)); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([204, '', null]); $this->client->voiceRecordings->delete('foo','bar','baz'); } @@ -113,7 +113,7 @@ public function testDownloadVoiceRecording() public function testCreateVoiceTranscription() { - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([201, '', '{ "data": [ { "id": "87c377ce-1629-48b6-ad01-4b4fd069c53c", @@ -127,7 +127,7 @@ public function testCreateVoiceTranscription() } } ] -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'calls/foo/legs/bar/recordings/baz/transcriptions', null, null); $this->client->voiceTranscriptions->create('foo', 'bar', 'baz'); } @@ -135,11 +135,11 @@ public function testCreateVoiceTranscription() public function testListVoiceTranscriptions() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'calls/foo/legs/bar/recordings/baz/transcriptions', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceTranscriptions->getList('foo', 'bar', 'baz', array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceTranscriptions->getList('foo', 'bar', 'baz', ['offset' => 100, 'limit' => 30]); } public function testReadVoiceTranscription() @@ -159,11 +159,11 @@ public function testDownloadVoiceTranscription() public function testListVoiceWebhooks() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'webhooks', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceWebhooks->getList(array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceWebhooks->getList(['offset' => 100, 'limit' => 30]); } public function testReadVoiceWebhook() @@ -179,7 +179,7 @@ public function testCreateVoiceWebhook() $webhook->url = 'https://example.com/'; $webhook->token = 'foobar'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([201, '', '{ "data": [ { "id": "534e1848-235f-482d-983d-e3e11a04f58a", @@ -201,7 +201,7 @@ public function testCreateVoiceWebhook() "currentPage": 1, "perPage": 10 } -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'webhooks', null, '{"url":"https:\/\/example.com\/","token":"foobar"}'); $this->client->voiceWebhooks->create($webhook); } @@ -212,7 +212,7 @@ public function testUpdateVoiceWebhook() $webhook->url = 'https://example.com/foo'; $webhook->token = 'foobar'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{ "data": [ { "id": "foobar123", @@ -225,14 +225,14 @@ public function testUpdateVoiceWebhook() "_links": { "self": "/webhooks/534e1848-235f-482d-983d-e3e11a04f58a" } -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("PUT", 'webhooks/foobar123', null, '{"url":"https:\/\/example.com\/foo","token":"foobar"}'); $this->client->voiceWebhooks->update($webhook, 'foobar123'); } public function testDeleteVoiceWebhook() { - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(204, '', null)); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([204, '', null]); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'webhooks/foobar123', null, ''); $this->client->voiceWebhooks->delete('foobar123'); } @@ -241,11 +241,11 @@ public function testDeleteVoiceWebhook() public function testListVoiceCallFlows() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows', array( + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'call-flows', [ 'offset' => 100, 'limit' => 30, - ), null); - $this->client->voiceCallFlows->getList(array('offset' => 100, 'limit' => 30)); + ], null); + $this->client->voiceCallFlows->getList(['offset' => 100, 'limit' => 30]); } public function testReadVoiceCallFlow() @@ -259,16 +259,16 @@ public function testCreateVoiceCallFlow() { $callFlow = new \MessageBird\Objects\Voice\CallFlow(); $callFlow->title = 'Foobar'; - $callFlow->steps = array( - array( + $callFlow->steps = [ + [ 'action' => 'transfer', - 'options' => array( + 'options' => [ 'destination' => '31612345678', - ), - ) , - ); + ], + ] , + ]; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(201, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([201, '', '{ "data": [ { "id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635", @@ -298,7 +298,7 @@ public function testCreateVoiceCallFlow() "currentPage": 1, "perPage": 10 } -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("POST", 'call-flows', null, '{"title":"Foobar","steps":[{"action":"transfer","options":{"destination":"31612345678"}}]}'); $this->client->voiceCallFlows->create($callFlow); } @@ -308,7 +308,7 @@ public function testUpdateVoiceCallFlow() $webhook = new \MessageBird\Objects\Voice\Webhook(); $webhook->title = 'Updated call flow'; - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(200, '', '{ + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([200, '', '{ "data": [ { "id": "de3ed163-d5fc-45f4-b8c4-7eea7458c635", @@ -329,14 +329,14 @@ public function testUpdateVoiceCallFlow() "_links": { "self": "/call-flows/de3ed163-d5fc-45f4-b8c4-7eea7458c635" } -}')); +}']); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("PUT", 'call-flows/foobar123', null, '{"title":"Updated call flow"}'); $this->client->voiceCallFlows->update($webhook, 'foobar123'); } public function testDeleteVoiceCallFlow() { - $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn(array(204, '', null)); + $this->mockClient->expects($this->atLeastOnce())->method('performHttpRequest')->willReturn([204, '', null]); $this->mockClient->expects($this->once())->method('performHttpRequest')->with("DELETE", 'call-flows/foobar123', null, ''); $this->client->voiceCallFlows->delete('foobar123'); } diff --git a/tests/integration/voicemessages/VoiceMessagesTest.php b/tests/integration/voicemessages/VoiceMessagesTest.php index 726e336a..cc16bd6c 100644 --- a/tests/integration/voicemessages/VoiceMessagesTest.php +++ b/tests/integration/voicemessages/VoiceMessagesTest.php @@ -12,7 +12,7 @@ public function testVoiceMessageCreate() $this->expectException(\MessageBird\Exceptions\ServerException::class); $Message = new \MessageBird\Objects\VoiceMessage(); $Message->originator = 'MessageBird'; - $Message->recipients = array(31612345678); + $Message->recipients = [31612345678]; $Message->body = 'This is a test message.'; $Message->language = "nl"; $Message->voice = "male"; @@ -23,8 +23,8 @@ public function testVoiceMessageCreate() public function testListMessage() { $this->expectException(\MessageBird\Exceptions\ServerException::class); - $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages', array ('offset' => 100, 'limit' => 30), null); - $this->client->voicemessages->getList(array ('offset' => 100, 'limit' => 30)); + $this->mockClient->expects($this->once())->method('performHttpRequest')->with("GET", 'voicemessages', ['offset' => 100, 'limit' => 30], null); + $this->client->voicemessages->getList( ['offset' => 100, 'limit' => 30]); } public function testReadMessage() diff --git a/tests/unit/RequestValidatorTest.php b/tests/unit/RequestValidatorTest.php index f01addd8..2b6341bd 100644 --- a/tests/unit/RequestValidatorTest.php +++ b/tests/unit/RequestValidatorTest.php @@ -8,7 +8,7 @@ class RequestValidatorTest extends TestCase { public function testVerify() { - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -16,7 +16,7 @@ public function testVerify() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='; $requestTimestamp = 1547198231; $body = ''; @@ -29,7 +29,7 @@ public function testVerify() public function testVerifyWithBody() { - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -37,7 +37,7 @@ public function testVerifyWithBody() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = 1547198231; $body = '{"foo":"bar"}'; @@ -50,7 +50,7 @@ public function testVerifyWithBody() public function testVerificationFails() { - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'BAR', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -58,7 +58,7 @@ public function testVerificationFails() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='; $requestTimestamp = 1547198231; $body = ''; @@ -71,7 +71,7 @@ public function testVerificationFails() public function testRecentRequest() { - $query = array(); + $query = []; $signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='; $requestTimestamp = time() - 1; $body = ''; @@ -84,7 +84,7 @@ public function testRecentRequest() public function testExpiredRequest() { - $query = array(); + $query = []; $signature = 'KVBdcVdz2lYMwcBLZCRITgxUfA/WkwSi+T3Wxl2HL6w='; $requestTimestamp = time() - 100; $body = ''; diff --git a/tests/unit/SignedRequestTest.php b/tests/unit/SignedRequestTest.php index 56f25de8..ef21fd4d 100644 --- a/tests/unit/SignedRequestTest.php +++ b/tests/unit/SignedRequestTest.php @@ -7,7 +7,7 @@ class SignedRequestTest extends TestCase { public function testCreate() { - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -15,7 +15,7 @@ public function testCreate() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = 1547198231; $body = '{"foo":"bar"}'; @@ -30,7 +30,7 @@ public function testCreate() public function testLoadFromArray() { - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -38,18 +38,18 @@ public function testLoadFromArray() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = 1547198231; $body = '{"foo":"bar"}'; $request = new SignedRequest(); - $request->loadFromArray(array( + $request->loadFromArray([ 'queryParameters' => $query, 'signature' => $signature, 'requestTimestamp' => $requestTimestamp, 'body' => $body - )); + ]); self::assertEquals($requestTimestamp, $request->requestTimestamp); self::assertEquals($body, $request->body); @@ -67,19 +67,19 @@ public function testLoadInvalidQuery() $body = '{"foo":"bar"}'; $request = new SignedRequest(); - $request->loadFromArray(array( + $request->loadFromArray([ 'queryParameters' => $query, 'signature' => $signature, 'requestTimestamp' => $requestTimestamp, 'body' => $body - )); + ]); } public function testLoadInvalidSignature() { $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('signature'); - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -87,25 +87,25 @@ public function testLoadInvalidSignature() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = null; $requestTimestamp = 1547198231; $body = '{"foo":"bar"}'; $request = new SignedRequest(); - $request->loadFromArray(array( + $request->loadFromArray([ 'queryParameters' => $query, 'signature' => $signature, 'requestTimestamp' => $requestTimestamp, 'body' => $body - )); + ]); } public function testLoadInvalidTimestamp() { $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('requestTimestamp'); - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -113,25 +113,25 @@ public function testLoadInvalidTimestamp() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = null; $body = '{"foo":"bar"}'; $request = new SignedRequest(); - $request->loadFromArray(array( + $request->loadFromArray([ 'queryParameters' => $query, 'signature' => $signature, 'requestTimestamp' => $requestTimestamp, 'body' => $body - )); + ]); } public function testLoadInvalidBody() { $this->expectException(\MessageBird\Exceptions\ValidationException::class); $this->expectExceptionMessage('body'); - $query = array( + $query = [ 'recipient' => '31612345678', 'reference' => 'FOO', 'statusDatetime' => '2019-01-11T09:17:11+00:00', @@ -139,17 +139,17 @@ public function testLoadInvalidBody() 'status' => 'delivered', 'mccmnc' => '20408', 'ported' => '1', - ); + ]; $signature = '2bl+38H4oHVg03pC3bk2LvCB0IHFgfC4cL5HPQ0LdmI='; $requestTimestamp = 1547198231; $body = null; $request = new SignedRequest(); - $request->loadFromArray(array( + $request->loadFromArray([ 'queryParameters' => $query, 'signature' => $signature, 'requestTimestamp' => $requestTimestamp, 'body' => $body - )); + ]); } }