From 94fbcf62645383929969d87bb867f67ff0a0f184 Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 26 Nov 2018 23:04:20 +0100 Subject: [PATCH] nitpick --- .../Http/Controllers/EchoController.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/LaravelEcho/Http/Controllers/EchoController.php b/src/LaravelEcho/Http/Controllers/EchoController.php index 280935c..c27dc6c 100644 --- a/src/LaravelEcho/Http/Controllers/EchoController.php +++ b/src/LaravelEcho/Http/Controllers/EchoController.php @@ -60,21 +60,23 @@ abstract class EchoController implements HttpServerInterface function onError(ConnectionInterface $connection, Exception $exception) { - if ($exception instanceof HttpException) { - $response = new Response($exception->getStatusCode(), [ - 'Content-Type' => 'application/json' - ], json_encode([ - 'error' => $exception->getMessage() - ])); - - $connection->send(Psr\str($response)); - $connection->close(); + if (! $exception instanceof HttpException) { + return; } + + $response = new Response($exception->getStatusCode(), [ + 'Content-Type' => 'application/json' + ], json_encode([ + 'error' => $exception->getMessage() + ])); + + $connection->send(Psr\str($response)); + $connection->close(); } public function ensureValidAppId(string $appId) { - if (! $client = Client::findByAppId($appId)) { + if (!$client = Client::findByAppId($appId)) { throw new HttpException(401, "Unknown app id `{$appId}` provided."); } @@ -86,10 +88,10 @@ abstract class EchoController implements HttpServerInterface $bodyMd5 = md5($request->getContent()); $signature = - "{$request->getMethod()}\n/{$request->path()}\n". - "auth_key={$request->get('auth_key')}". - "&auth_timestamp={$request->get('auth_timestamp')}". - "&auth_version={$request->get('auth_version')}". + "{$request->getMethod()}\n/{$request->path()}\n" . + "auth_key={$request->get('auth_key')}" . + "&auth_timestamp={$request->get('auth_timestamp')}" . + "&auth_version={$request->get('auth_version')}" . "&body_md5={$bodyMd5}"; $authSignature = hash_hmac('sha256', $signature, Client::findByAppId($request->get('appId'))->appSecret);