Skip to content

Commit

Permalink
Apply fixes from StyleCI (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot authored Mar 7, 2018
1 parent 7fc051a commit 2e88f1a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 31 deletions.
51 changes: 29 additions & 22 deletions src/HangoutsDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -24,6 +24,7 @@ class HangoutsDriver extends HttpDriver

/**
* @param Request $request
*
* @return void
*/
public function buildPayload(Request $request)
Expand Down Expand Up @@ -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)
Expand All @@ -115,6 +118,7 @@ public function getUser(IncomingMessage $matchingMessage)

/**
* @param \BotMan\BotMan\Messages\Incoming\IncomingMessage $message
*
* @return Answer
*/
public function getConversationAnswer(IncomingMessage $message)
Expand All @@ -124,35 +128,36 @@ 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();

$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) {
Expand All @@ -164,6 +169,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam

/**
* @param mixed $payload
*
* @return Response
*/
public function sendPayload($payload)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Providers/HangoutsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -16,7 +16,7 @@ class HangoutsServiceProvider extends ServiceProvider
*/
public function boot()
{
if (! $this->isRunningInBotManStudio()) {
if (!$this->isRunningInBotManStudio()) {
$this->loadDrivers();

$this->publishes([
Expand Down
14 changes: 7 additions & 7 deletions tests/HangoutsDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]');
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 2e88f1a

Please sign in to comment.