From 2e88f1a1589d4d09e5626652a42fef843eef5600 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 7 Mar 2018 20:32:54 +0100 Subject: [PATCH] Apply fixes from StyleCI (#1) --- src/HangoutsDriver.php | 51 +++++++++++++---------- src/Providers/HangoutsServiceProvider.php | 4 +- tests/HangoutsDriverTest.php | 14 +++---- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/HangoutsDriver.php b/src/HangoutsDriver.php index c31a43d..fc78c87 100644 --- a/src/HangoutsDriver.php +++ b/src/HangoutsDriver.php @@ -2,19 +2,19 @@ namespace BotMan\Drivers\Hangouts; -use BotMan\BotMan\Users\User; -use Illuminate\Support\Collection; +use BotMan\BotMan\Drivers\Events\GenericEvent; use BotMan\BotMan\Drivers\HttpDriver; +use BotMan\BotMan\Messages\Attachments\Image; use BotMan\BotMan\Messages\Incoming\Answer; +use BotMan\BotMan\Messages\Incoming\IncomingMessage; +use BotMan\BotMan\Messages\Outgoing\OutgoingMessage; use BotMan\BotMan\Messages\Outgoing\Question; +use BotMan\BotMan\Users\User; +use Illuminate\Support\Collection; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; -use BotMan\BotMan\Messages\Attachments\Image; use Symfony\Component\HttpFoundation\Response; -use BotMan\BotMan\Drivers\Events\GenericEvent; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\HttpFoundation\JsonResponse; -use BotMan\BotMan\Messages\Incoming\IncomingMessage; -use BotMan\BotMan\Messages\Outgoing\OutgoingMessage; class HangoutsDriver extends HttpDriver { @@ -24,6 +24,7 @@ class HangoutsDriver extends HttpDriver /** * @param Request $request + * * @return void */ public function buildPayload(Request $request) @@ -96,12 +97,14 @@ protected function loadMessages() */ public function isConfigured() { - return ! empty($this->config->get('token')); + return !empty($this->config->get('token')); } /** * Retrieve User information. + * * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage + * * @return User */ public function getUser(IncomingMessage $matchingMessage) @@ -115,6 +118,7 @@ public function getUser(IncomingMessage $matchingMessage) /** * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $message + * * @return Answer */ public function getConversationAnswer(IncomingMessage $message) @@ -124,23 +128,24 @@ public function getConversationAnswer(IncomingMessage $message) /** * @param OutgoingMessage|\BotMan\BotMan\Messages\Outgoing\Question $message - * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage - * @param array $additionalParameters + * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage + * @param array $additionalParameters + * * @return array */ public function buildServicePayload($message, $matchingMessage, $additionalParameters = []) { $payload = [ - 'text' => '', + 'text' => '', 'cards' => [ [ 'sections' => [ [ - 'widgets' => [] - ] - ] - ] - ] + 'widgets' => [], + ], + ], + ], + ], ]; if ($message instanceof OutgoingMessage) { $text = $message->getText(); @@ -148,11 +153,11 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam $payload['text'] = $text; $attachment = $message->getAttachment(); - if (! is_null($attachment) && $attachment instanceof Image) { + if (!is_null($attachment) && $attachment instanceof Image) { $payload['cards'][0]['sections'][0]['widgets'][] = [ 'image' => [ - 'imageUrl' => $attachment->getUrl() - ] + 'imageUrl' => $attachment->getUrl(), + ], ]; } } elseif ($message instanceof Question) { @@ -164,6 +169,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam /** * @param mixed $payload + * * @return Response */ public function sendPayload($payload) @@ -174,9 +180,10 @@ public function sendPayload($payload) /** * Low-level method to perform driver specific API requests. * - * @param string $endpoint - * @param array $parameters + * @param string $endpoint + * @param array $parameters * @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $matchingMessage + * * @return void */ public function sendRequest($endpoint, array $parameters, IncomingMessage $matchingMessage) diff --git a/src/Providers/HangoutsServiceProvider.php b/src/Providers/HangoutsServiceProvider.php index 7de00ec..eb6500d 100644 --- a/src/Providers/HangoutsServiceProvider.php +++ b/src/Providers/HangoutsServiceProvider.php @@ -2,10 +2,10 @@ namespace BotMan\Drivers\Hangouts\Providers; -use Illuminate\Support\ServiceProvider; use BotMan\BotMan\Drivers\DriverManager; use BotMan\Drivers\Hangouts\HangoutsDriver; use BotMan\Studio\Providers\StudioServiceProvider; +use Illuminate\Support\ServiceProvider; class HangoutsServiceProvider extends ServiceProvider { @@ -16,7 +16,7 @@ class HangoutsServiceProvider extends ServiceProvider */ public function boot() { - if (! $this->isRunningInBotManStudio()) { + if (!$this->isRunningInBotManStudio()) { $this->loadDrivers(); $this->publishes([ diff --git a/tests/HangoutsDriverTest.php b/tests/HangoutsDriverTest.php index 16fe62e..3e5541d 100644 --- a/tests/HangoutsDriverTest.php +++ b/tests/HangoutsDriverTest.php @@ -2,12 +2,12 @@ namespace Tests; +use BotMan\BotMan\Http\Curl; use BotMan\BotMan\Messages\Attachments\Image; use BotMan\BotMan\Messages\Outgoing\OutgoingMessage; +use BotMan\Drivers\Hangouts\HangoutsDriver; use Mockery as m; -use BotMan\BotMan\Http\Curl; use PHPUnit_Framework_TestCase; -use BotMan\Drivers\Hangouts\HangoutsDriver; use Symfony\Component\HttpFoundation\Request; class HangoutsDriverTest extends PHPUnit_Framework_TestCase @@ -22,7 +22,7 @@ public function tearDown() private function getValidDriver($fixture = 'dm', $config = null) { $config = $config ?? [ - 'token' => self::TEST_TOKEN + 'token' => self::TEST_TOKEN, ]; $request = m::mock(Request::class.'[getContent]'); @@ -87,15 +87,15 @@ public function it_returns_the_message_text() public function it_strips_annotations() { $driver = $this->getValidDriver('annotation', [ - 'token' => self::TEST_TOKEN, - 'strip_annotations' => false + 'token' => self::TEST_TOKEN, + 'strip_annotations' => false, ]); $this->assertSame('hey @botman hi', $driver->getMessages()[0]->getText()); $driver = $this->getValidDriver('annotation', [ - 'token' => self::TEST_TOKEN, - 'strip_annotations' => true + 'token' => self::TEST_TOKEN, + 'strip_annotations' => true, ]); $this->assertSame('hi', $driver->getMessages()[0]->getText());