From f95be60669a88d9a6ab2dff0e50408c494a7227e Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Sat, 4 Nov 2023 06:30:15 +0100 Subject: [PATCH] Apply fixes from StyleCI (#124) --- src/Events/FacebookEvent.php | 2 +- src/Extensions/ButtonTemplate.php | 2 +- src/Extensions/Element.php | 2 +- src/Extensions/ElementButton.php | 2 +- src/Extensions/MediaAttachmentElement.php | 6 ++-- src/Extensions/MediaTemplate.php | 2 +- src/Extensions/MediaUrlElement.php | 6 ++-- src/Extensions/QuickReplyButton.php | 2 +- src/Extensions/ReceiptAddress.php | 6 ++-- src/Extensions/ReceiptAdjustment.php | 4 +-- src/Extensions/ReceiptElement.php | 8 ++--- src/Extensions/ReceiptSummary.php | 4 +-- src/Extensions/ReceiptTemplate.php | 14 ++++----- src/FacebookDriver.php | 36 +++++++++++------------ 14 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Events/FacebookEvent.php b/src/Events/FacebookEvent.php index 6e0ff3b..f774b9b 100644 --- a/src/Events/FacebookEvent.php +++ b/src/Events/FacebookEvent.php @@ -9,7 +9,7 @@ abstract class FacebookEvent implements DriverEventInterface protected $payload; /** - * @param $payload + * @param $payload */ public function __construct($payload) { diff --git a/src/Extensions/ButtonTemplate.php b/src/Extensions/ButtonTemplate.php index 8f6b10e..31160c8 100644 --- a/src/Extensions/ButtonTemplate.php +++ b/src/Extensions/ButtonTemplate.php @@ -14,7 +14,7 @@ class ButtonTemplate implements JsonSerializable, WebAccess protected $buttons = []; /** - * @param $text + * @param $text * @return static */ public static function create($text) diff --git a/src/Extensions/Element.php b/src/Extensions/Element.php index 699e061..57b4a02 100644 --- a/src/Extensions/Element.php +++ b/src/Extensions/Element.php @@ -25,7 +25,7 @@ class Element implements JsonSerializable protected $default_action; /** - * @param $title + * @param $title * @return static */ public static function create($title) diff --git a/src/Extensions/ElementButton.php b/src/Extensions/ElementButton.php index 83c93a2..79e9097 100755 --- a/src/Extensions/ElementButton.php +++ b/src/Extensions/ElementButton.php @@ -87,7 +87,7 @@ public function type($type) } /** - * @param $payload + * @param $payload * @return $this */ public function payload($payload) diff --git a/src/Extensions/MediaAttachmentElement.php b/src/Extensions/MediaAttachmentElement.php index 6b16bb5..a1650d8 100644 --- a/src/Extensions/MediaAttachmentElement.php +++ b/src/Extensions/MediaAttachmentElement.php @@ -16,7 +16,7 @@ class MediaAttachmentElement implements JsonSerializable protected $buttons; /** - * @param $mediaType + * @param $mediaType * @return static */ public static function create($mediaType) @@ -25,7 +25,7 @@ public static function create($mediaType) } /** - * @param $mediaType + * @param $mediaType */ public function __construct($mediaType) { @@ -33,7 +33,7 @@ public function __construct($mediaType) } /** - * @param $attachmentId + * @param $attachmentId * @return $this */ public function attachmentId($attachmentId) diff --git a/src/Extensions/MediaTemplate.php b/src/Extensions/MediaTemplate.php index 0a468ed..a83df13 100644 --- a/src/Extensions/MediaTemplate.php +++ b/src/Extensions/MediaTemplate.php @@ -22,7 +22,7 @@ public static function create() } /** - * @param $element + * @param $element * @return $this */ public function element($element) diff --git a/src/Extensions/MediaUrlElement.php b/src/Extensions/MediaUrlElement.php index a8ccc41..73bf112 100644 --- a/src/Extensions/MediaUrlElement.php +++ b/src/Extensions/MediaUrlElement.php @@ -16,7 +16,7 @@ class MediaUrlElement implements JsonSerializable protected $buttons; /** - * @param $mediaType + * @param $mediaType * @return static */ public static function create($mediaType) @@ -25,7 +25,7 @@ public static function create($mediaType) } /** - * @param $mediaType + * @param $mediaType */ public function __construct($mediaType) { @@ -33,7 +33,7 @@ public function __construct($mediaType) } /** - * @param $url + * @param $url * @return $this */ public function url($url) diff --git a/src/Extensions/QuickReplyButton.php b/src/Extensions/QuickReplyButton.php index 560a77f..c08d635 100644 --- a/src/Extensions/QuickReplyButton.php +++ b/src/Extensions/QuickReplyButton.php @@ -51,7 +51,7 @@ public function type($type) } /** - * @param $payload + * @param $payload * @return $this */ public function payload($payload) diff --git a/src/Extensions/ReceiptAddress.php b/src/Extensions/ReceiptAddress.php index e691dc4..311e4f5 100644 --- a/src/Extensions/ReceiptAddress.php +++ b/src/Extensions/ReceiptAddress.php @@ -55,7 +55,7 @@ public function street2($street) } /** - * @param $city + * @param $city * @return $this */ public function city($city) @@ -66,7 +66,7 @@ public function city($city) } /** - * @param $postalCode + * @param $postalCode * @return $this */ public function postalCode($postalCode) @@ -77,7 +77,7 @@ public function postalCode($postalCode) } /** - * @param $state + * @param $state * @return $this */ public function state($state) diff --git a/src/Extensions/ReceiptAdjustment.php b/src/Extensions/ReceiptAdjustment.php index 9f4443a..cdcd72a 100644 --- a/src/Extensions/ReceiptAdjustment.php +++ b/src/Extensions/ReceiptAdjustment.php @@ -13,7 +13,7 @@ class ReceiptAdjustment implements JsonSerializable protected $amount; /** - * @param $name + * @param $name * @return static */ public static function create($name) @@ -24,7 +24,7 @@ public static function create($name) /** * ReceiptAdjustment constructor. * - * @param $name + * @param $name */ public function __construct($name) { diff --git a/src/Extensions/ReceiptElement.php b/src/Extensions/ReceiptElement.php index 2d9208d..3c28c29 100644 --- a/src/Extensions/ReceiptElement.php +++ b/src/Extensions/ReceiptElement.php @@ -25,7 +25,7 @@ class ReceiptElement implements JsonSerializable protected $image_url; /** - * @param $title + * @param $title * @return static */ public static function create($title) @@ -53,7 +53,7 @@ public function subtitle($subtitle) } /** - * @param $quantity + * @param $quantity * @return $this */ public function quantity($quantity) @@ -64,7 +64,7 @@ public function quantity($quantity) } /** - * @param $price + * @param $price * @return $this */ public function price($price) @@ -75,7 +75,7 @@ public function price($price) } /** - * @param $currency + * @param $currency * @return $this */ public function currency($currency) diff --git a/src/Extensions/ReceiptSummary.php b/src/Extensions/ReceiptSummary.php index fda8d5b..6d71907 100644 --- a/src/Extensions/ReceiptSummary.php +++ b/src/Extensions/ReceiptSummary.php @@ -49,7 +49,7 @@ public function shippingCost($shippingCost) } /** - * @param $totalTax + * @param $totalTax * @return $this */ public function totalTax($totalTax) @@ -60,7 +60,7 @@ public function totalTax($totalTax) } /** - * @param $totalCost + * @param $totalCost * @return $this */ public function totalCost($totalCost) diff --git a/src/Extensions/ReceiptTemplate.php b/src/Extensions/ReceiptTemplate.php index 7997213..ace4d23 100644 --- a/src/Extensions/ReceiptTemplate.php +++ b/src/Extensions/ReceiptTemplate.php @@ -49,7 +49,7 @@ public static function create() } /** - * @param $name + * @param $name * @return $this */ public function recipientName($name) @@ -60,7 +60,7 @@ public function recipientName($name) } /** - * @param $name + * @param $name * @return $this */ public function merchantName($name) @@ -71,7 +71,7 @@ public function merchantName($name) } /** - * @param $orderNumber + * @param $orderNumber * @return $this */ public function orderNumber($orderNumber) @@ -82,7 +82,7 @@ public function orderNumber($orderNumber) } /** - * @param $currency + * @param $currency * @return $this */ public function currency($currency) @@ -93,7 +93,7 @@ public function currency($currency) } /** - * @param $paymentMethod + * @param $paymentMethod * @return $this */ public function paymentMethod($paymentMethod) @@ -104,7 +104,7 @@ public function paymentMethod($paymentMethod) } /** - * @param $orderUrl + * @param $orderUrl * @return $this */ public function orderUrl($orderUrl) @@ -115,7 +115,7 @@ public function orderUrl($orderUrl) } /** - * @param $timestamp + * @param $timestamp * @return $this */ public function timestamp($timestamp) diff --git a/src/FacebookDriver.php b/src/FacebookDriver.php index a0b3645..75e3a71 100755 --- a/src/FacebookDriver.php +++ b/src/FacebookDriver.php @@ -104,10 +104,10 @@ public function matchesRequest() { $validSignature = empty($this->config->get('app_secret')) || $this->validateSignature(); $messages = Collection::make($this->event->get('messaging'))->filter(function ($msg) { - return (isset($msg['message']['text']) || isset($msg['postback']['payload'])) && !isset($msg['message']['is_echo']); + return (isset($msg['message']['text']) || isset($msg['postback']['payload'])) && ! isset($msg['message']['is_echo']); }); - return !$messages->isEmpty() && $validSignature; + return ! $messages->isEmpty() && $validSignature; } /** @@ -139,7 +139,7 @@ public function hasMatchingEvent() return Collection::make($msg)->toArray(); })->first(); - if (!is_null($event)) { + if (! is_null($event)) { $this->driverEvent = $this->getEventFromEventData($event); return $this->driverEvent; @@ -197,7 +197,7 @@ protected function validateSignature() { return hash_equals( $this->signature, - 'sha1=' . hash_hmac('sha1', $this->content, $this->config->get('app_secret')) + 'sha1='.hash_hmac('sha1', $this->content, $this->config->get('app_secret')) ); } @@ -215,7 +215,7 @@ public function markSeen(IncomingMessage $matchingMessage) 'sender_action' => 'mark_seen', ]; - return $this->http->post($this->facebookProfileEndpoint . 'me/messages', [], $parameters); + return $this->http->post($this->facebookProfileEndpoint.'me/messages', [], $parameters); } /** @@ -232,7 +232,7 @@ public function types(IncomingMessage $matchingMessage) 'sender_action' => 'typing_on', ]; - return $this->http->post($this->facebookProfileEndpoint . 'me/messages', [], $parameters); + return $this->http->post($this->facebookProfileEndpoint.'me/messages', [], $parameters); } /** @@ -273,7 +273,7 @@ protected function loadMessages() $messages = Collection::make($this->event->get('messaging')); $messages = $messages->transform(function ($msg) { $message = new IncomingMessage('', $this->getMessageSender($msg), $this->getMessageRecipient($msg), $msg); - if (isset($msg['message']['text']) && !isset($msg['message']['quick_reply']['payload'])) { + if (isset($msg['message']['text']) && ! isset($msg['message']['quick_reply']['payload'])) { $message->setText($msg['message']['text']); if (isset($msg['message']['nlp'])) { @@ -384,7 +384,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam $parameters['message'] = $message->toArray(); } elseif ($message instanceof OutgoingMessage) { $attachment = $message->getAttachment(); - if (!is_null($attachment) && in_array(get_class($attachment), $this->supportedAttachments)) { + if (! is_null($attachment) && in_array(get_class($attachment), $this->supportedAttachments)) { $attachmentType = strtolower(basename(str_replace('\\', '/', get_class($attachment)))); unset($parameters['message']['text']); $parameters['message']['attachment'] = [ @@ -412,7 +412,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam */ public function sendPayload($payload) { - $response = $this->http->post($this->facebookProfileEndpoint . 'me/messages', [], $payload); + $response = $this->http->post($this->facebookProfileEndpoint.'me/messages', [], $payload); $this->throwExceptionIfResponseNotOk($response); return $response; @@ -423,7 +423,7 @@ public function sendPayload($payload) */ public function isConfigured() { - return !empty($this->config->get('token')); + return ! empty($this->config->get('token')); } /** @@ -445,7 +445,7 @@ public function getUserWithFields(array $fields, IncomingMessage $matchingMessag if (isset($messagingDetails['sender']['community'])) { $fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time'; } - $userInfoData = $this->http->get($this->facebookProfileEndpoint . $matchingMessage->getSender() . '?fields=' . $fields . '&access_token=' . $this->config->get('token')); + $userInfoData = $this->http->get($this->facebookProfileEndpoint.$matchingMessage->getSender().'?fields='.$fields.'&access_token='.$this->config->get('token')); $this->throwExceptionIfResponseNotOk($userInfoData); $userInfo = json_decode($userInfoData->getContent(), true); $firstName = $userInfo['first_name'] ?? null; @@ -475,7 +475,7 @@ public function getUser(IncomingMessage $matchingMessage) $fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time'; } - $userInfoData = $this->http->get($this->facebookProfileEndpoint . $matchingMessage->getSender() . '?fields=' . $fields . '&access_token=' . $this->config->get('token')); + $userInfoData = $this->http->get($this->facebookProfileEndpoint.$matchingMessage->getSender().'?fields='.$fields.'&access_token='.$this->config->get('token')); $this->throwExceptionIfResponseNotOk($userInfoData); $userInfo = json_decode($userInfoData->getContent(), true); @@ -500,7 +500,7 @@ public function sendRequest($endpoint, array $parameters, IncomingMessage $match 'access_token' => $this->config->get('token'), ], $parameters); - return $this->http->post($this->facebookProfileEndpoint . $endpoint, [], $parameters); + return $this->http->post($this->facebookProfileEndpoint.$endpoint, [], $parameters); } /** @@ -521,12 +521,12 @@ protected function throwExceptionIfResponseNotOk(Response $facebookResponse) { if ($facebookResponse->getStatusCode() !== 200) { $responseData = json_decode($facebookResponse->getContent(), true); - throw new FacebookException('Error sending payload: ' . $responseData['error']['message']); + throw new FacebookException('Error sending payload: '.$responseData['error']['message']); } } /** - * @param $msg + * @param $msg * @return string|null */ protected function getMessageSender($msg) @@ -539,7 +539,7 @@ protected function getMessageSender($msg) } /** - * @param $msg + * @param $msg * @return string|null */ protected function getMessageRecipient($msg) @@ -553,12 +553,12 @@ protected function getMessageRecipient($msg) * Pass a conversation to the page inbox. * * @param IncomingMessage $message - * @param $bot + * @param $bot * @return Response */ public function handover(IncomingMessage $message, $bot) { - return $this->http->post($this->facebookProfileEndpoint . 'me/pass_thread_control?access_token=' . $this->config->get('token'), [], [ + return $this->http->post($this->facebookProfileEndpoint.'me/pass_thread_control?access_token='.$this->config->get('token'), [], [ 'recipient' => [ 'id' => $message->getSender(), ],