22
33namespace NotificationChannels \Discord ;
44
5+ use Exception ;
56use Illuminate \Support \Arr ;
67use GuzzleHttp \Client as HttpClient ;
78use GuzzleHttp \Exception \RequestException ;
89use NotificationChannels \Discord \Exceptions \CouldNotSendNotification ;
910
1011class Discord
1112{
12- /**
13- * @var string
14- */
13+ /** @var string */
1514 protected $ baseUrl = 'https://discordapp.com/api ' ;
1615
17- /**
18- * @var \GuzzleHttp\Client
19- */
20- protected $ http ;
16+ /** @var \GuzzleHttp\Client */
17+ protected $ httpClient ;
2118
22- /**
23- * @var string
24- */
19+ /** @var string */
2520 protected $ token ;
2621
2722 /**
@@ -30,13 +25,14 @@ class Discord
3025 */
3126 public function __construct (HttpClient $ http , $ token )
3227 {
33- $ this ->http = $ http ;
28+ $ this ->httpClient = $ http ;
3429 $ this ->token = $ token ;
3530 }
3631
3732 /**
3833 * @param string $channel
3934 * @param array $data
35+ *
4036 * @return \Psr\Http\Message\ResponseInterface
4137 */
4238 public function send ($ channel , array $ data )
@@ -46,6 +42,7 @@ public function send($channel, array $data)
4642
4743 /**
4844 * @param mixed $user
45+ *
4946 * @return string
5047 */
5148 public function getPrivateChannel ($ user )
@@ -54,26 +51,29 @@ public function getPrivateChannel($user)
5451 }
5552
5653 /**
57- * @param string $endpoint
58- * @param array $data
54+ * @param $verb
55+ * @param string $endpoint
56+ * @param array $data
57+ *
5958 * @return array
59+ *
6060 * @throws \NotificationChannels\Discord\Exceptions\CouldNotSendNotification
6161 */
6262 protected function request ($ verb , $ endpoint , array $ data )
6363 {
6464 $ url = rtrim ($ this ->baseUrl , '/ ' ).'/ ' .ltrim ($ endpoint , '/ ' );
6565
6666 try {
67- $ response = $ this ->http ->request ($ verb , $ url , [
67+ $ response = $ this ->httpClient ->request ($ verb , $ url , [
6868 'headers ' => [
6969 'Authorization ' => 'Bot ' .$ this ->token ,
7070 ],
7171 'json ' => $ data ,
7272 ]);
73- } catch (RequestException $ e ) {
74- throw CouldNotSendNotification::serviceRespondedWithAnHttpError ($ e ->getResponse ());
75- } catch (\ Exception $ e ) {
76- throw CouldNotSendNotification::serviceCommunicationError ($ e );
73+ } catch (RequestException $ exception ) {
74+ throw CouldNotSendNotification::serviceRespondedWithAnHttpError ($ exception ->getResponse ());
75+ } catch (Exception $ exception ) {
76+ throw CouldNotSendNotification::serviceCommunicationError ($ exception );
7777 }
7878
7979 $ body = json_decode ($ response ->getBody (), true );
0 commit comments