Skip to content

Commit 43aeeaf

Browse files
committed
rename exception from CouldNotSendNotification to CouldNotSendMobilyWsNotification
1 parent ee119ae commit 43aeeaf

11 files changed

+40
-40
lines changed

src/Exceptions/CouldNotSendNotification.php renamed to src/Exceptions/CouldNotSendMobilyWsNotification.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use GuzzleHttp\Psr7\Response;
66
use GuzzleHttp\Exception\RequestException;
77

8-
class CouldNotSendNotification extends \Exception
8+
class CouldNotSendMobilyWsNotification extends \Exception
99
{
1010
/**
1111
* Thrown when mobily.ws return a response body other than '1'.

src/MobilyWsApi.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use GuzzleHttp\Client as HttpClient;
66
use GuzzleHttp\Exception\RequestException;
7-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
7+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
88

99
class MobilyWsApi
1010
{
@@ -72,7 +72,7 @@ public function sendMessage(MobilyWsMessage $message, $number)
7272
* @param array $payload
7373
*
7474
* @return array
75-
* @throws \NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification
75+
* @throws \NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification
7676
* @internal param array $params
7777
*
7878
*/
@@ -87,9 +87,9 @@ public function send(array $payload)
8787
'message' => $this->msgSendResponse($code),
8888
];
8989
}
90-
throw CouldNotSendNotification::someErrorWhenSendingSms($response);
90+
throw CouldNotSendMobilyWsNotification::someErrorWhenSendingSms($response);
9191
} catch (RequestException $exception) {
92-
throw CouldNotSendNotification::couldNotSendRequestToMobilyWs($exception);
92+
throw CouldNotSendMobilyWsNotification::couldNotSendRequestToMobilyWs($exception);
9393
}
9494
}
9595

src/MobilyWsChannel.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Events\Dispatcher;
66
use Illuminate\Notifications\Events\NotificationFailed;
77
use Illuminate\Notifications\Notification;
8-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
8+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
99

1010
class MobilyWsChannel
1111
{
@@ -35,12 +35,12 @@ public function __construct(MobilyWsApi $mobilyWs, Dispatcher $events)
3535
*
3636
* @return string
3737
*
38-
* @throws \NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification
38+
* @throws \NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification
3939
*/
4040
public function send($notifiable, Notification $notification)
4141
{
4242
if (!method_exists($notification, 'toMobilyWs')) {
43-
throw CouldNotSendNotification::withErrorMessage('MobilyWs notifications must have toMobilyWs method');
43+
throw CouldNotSendMobilyWsNotification::withErrorMessage('MobilyWs notifications must have toMobilyWs method');
4444
}
4545
$message = $notification->toMobilyWs($notifiable, new MobilyWsMessage());
4646
$number = $notifiable->routeNotificationFor('MobilyWs') ?: $notifiable->phone_number;
@@ -55,7 +55,7 @@ public function send($notifiable, Notification $notification)
5555
new NotificationFailed($notifiable, $notification, 'mobily-ws', $response)
5656
);
5757

58-
throw CouldNotSendNotification::mobilyWsRespondedWithAnError($response['code'], $response['message']);
58+
throw CouldNotSendMobilyWsNotification::mobilyWsRespondedWithAnError($response['code'], $response['message']);
5959
}
6060

6161
/**
@@ -64,7 +64,7 @@ public function send($notifiable, Notification $notification)
6464
*
6565
* @return array
6666
*
67-
* @throws CouldNotSendNotification
67+
* @throws CouldNotSendMobilyWsNotification
6868
*/
6969
private function dispatchRequest($message, $number)
7070
{
@@ -80,7 +80,7 @@ private function dispatchRequest($message, $number)
8080
MobilyWsMessage::class,
8181
gettype($message)
8282
);
83-
throw CouldNotSendNotification::withErrorMessage($errorMessage);
83+
throw CouldNotSendMobilyWsNotification::withErrorMessage($errorMessage);
8484
}
8585

8686
return $response;

src/MobilyWsConfig.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace NotificationChannels\MobilyWs;
44

5-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
5+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
66

77
class MobilyWsConfig
88
{
@@ -75,14 +75,14 @@ protected function setAuthenticationMethod($config)
7575
return $this->authMethod = $config['authentication'];
7676
}
7777

78-
throw CouldNotSendNotification::withErrorMessage(
78+
throw CouldNotSendMobilyWsNotification::withErrorMessage(
7979
sprintf('Method %s is not supported. Please choose from: (apiKey, password, auto)',
8080
$config['authentication']
8181
)
8282
);
8383
}
8484

85-
throw CouldNotSendNotification::withErrorMessage('Please set the authentication method in the mobilyws config file');
85+
throw CouldNotSendMobilyWsNotification::withErrorMessage('Please set the authentication method in the mobilyws config file');
8686
}
8787

8888
protected function getAutoCredentials()
@@ -102,7 +102,7 @@ protected function getAutoCredentials()
102102
protected function validateCredentials()
103103
{
104104
if (!isset($this->config['apiKey']) && !isset($this->config['mobile'], $this->config['password'])) {
105-
throw CouldNotSendNotification::withErrorMessage('No credentials were provided. Please set your (mobile/password) or apiKey in the config file');
105+
throw CouldNotSendMobilyWsNotification::withErrorMessage('No credentials were provided. Please set your (mobile/password) or apiKey in the config file');
106106
}
107107
}
108108
}

src/MobilyWsMessage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Carbon\Carbon;
66
use DateTime;
77
use DateTimeInterface;
8-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
8+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
99

1010
class MobilyWsMessage
1111
{
@@ -58,7 +58,7 @@ public function text($text)
5858
*
5959
* @return $this
6060
*
61-
* @throws CouldNotSendNotification
61+
* @throws CouldNotSendMobilyWsNotification
6262
*/
6363
public function time($time)
6464
{
@@ -72,7 +72,7 @@ public function time($time)
7272
return $this;
7373
}
7474

75-
throw CouldNotSendNotification::withErrorMessage(
75+
throw CouldNotSendMobilyWsNotification::withErrorMessage(
7676
sprintf('Time must be a timestamp or an object implementing DateTimeInterface. %s is given', gettype($time))
7777
);
7878
}

src/MobilyWsServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use GuzzleHttp\Client;
66
use Illuminate\Support\ServiceProvider;
77
use NotificationChannels\MobilyWs\Console\MobilyWsNotificationMakeCommand;
8-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
8+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
99

1010
class MobilyWsServiceProvider extends ServiceProvider
1111
{
@@ -19,7 +19,7 @@ public function boot()
1919
->give(function () {
2020
$mobilyWsConfig = $this->app['config']['mobilyws'];
2121
if (is_null($mobilyWsConfig)) {
22-
throw CouldNotSendNotification::withErrorMessage('Config file was not found. Please publish the config file');
22+
throw CouldNotSendMobilyWsNotification::withErrorMessage('Config file was not found. Please publish the config file');
2323
}
2424

2525
return new MobilyWsApi(

tests/ApiTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function GuzzleHttp\Psr7\parse_query;
1313
use NotificationChannels\MobilyWs\MobilyWsApi;
1414
use NotificationChannels\MobilyWs\MobilyWsConfig;
15-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
15+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
1616
use NotificationChannels\MobilyWs\MobilyWsMessage;
1717

1818
class ApiTest extends TestCase
@@ -245,14 +245,14 @@ public function it_throw_an_exception_when_response_is_not_ok()
245245

246246
try {
247247
$api->send($params);
248-
} catch (CouldNotSendNotification $e) {
248+
} catch (CouldNotSendMobilyWsNotification $e) {
249249
$this->assertContains('Request to mobily.ws failed', $e->getMessage());
250250
$this->assertEquals('403', $e->getCode());
251251

252252
return;
253253
}
254254

255-
$this->fail('CouldNotSendNotification exception was not raised');
255+
$this->fail('CouldNotSendMobilyWsNotification exception was not raised');
256256
}
257257

258258
/**

tests/ChannelTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Notifications\Notification;
99
use NotificationChannels\MobilyWs\MobilyWsApi;
1010
use NotificationChannels\MobilyWs\MobilyWsChannel;
11-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
11+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
1212
use NotificationChannels\MobilyWs\MobilyWsMessage;
1313

1414
/**
@@ -79,7 +79,7 @@ public function it_throw_an_exception_when_given_a_message_other_than_string_or_
7979

8080
try {
8181
$this->channel->send($this->notifiable, $notificationWithArray);
82-
} catch (CouldNotSendNotification $e) {
82+
} catch (CouldNotSendMobilyWsNotification $e) {
8383
$this->assertContains(
8484
'toMobilyWs must return a string or instance of NotificationChannels\MobilyWs\MobilyWsMessage. Instance of array returned',
8585
$e->getMessage()
@@ -88,11 +88,11 @@ public function it_throw_an_exception_when_given_a_message_other_than_string_or_
8888
return;
8989
}
9090

91-
$this->fail('CouldNotSendNotification exception was not raised');
91+
$this->fail('CouldNotSendMobilyWsNotification exception was not raised');
9292
}
9393

9494
/** @test
95-
* @expectedException \NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
95+
* @expectedException \NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
9696
*/
9797
public function it_fires_failure_event_on_failure()
9898
{
@@ -104,7 +104,7 @@ public function it_fires_failure_event_on_failure()
104104

105105
try {
106106
$this->channel->send($this->notifiable, new TestNotification('Text message'));
107-
} catch (CouldNotSendNotification $e) {
107+
} catch (CouldNotSendMobilyWsNotification $e) {
108108
$this->events->shouldHaveReceived('fire');
109109
}
110110
}
@@ -120,27 +120,27 @@ public function it_throw_an_exception_when_mobily_ws_return_an_error()
120120

121121
try {
122122
$this->channel->send($this->notifiable, new TestNotification('Text message'));
123-
} catch (CouldNotSendNotification $e) {
123+
} catch (CouldNotSendMobilyWsNotification $e) {
124124
$this->assertContains('رصيدك غير كافي لإتمام عملية الإرسال', $e->getMessage());
125125

126126
return;
127127
}
128128

129-
$this->fail('CouldNotSendNotification exception was not raised');
129+
$this->fail('CouldNotSendMobilyWsNotification exception was not raised');
130130
}
131131

132132
/** @test */
133133
public function it_throw_an_exception_when_toMobilyWs_method_does_not_exist()
134134
{
135135
try {
136136
$this->channel->send($this->notifiable, new Notification());
137-
} catch (CouldNotSendNotification $e) {
137+
} catch (CouldNotSendMobilyWsNotification $e) {
138138
$this->assertContains('MobilyWs notifications must have toMobilyWs method', $e->getMessage());
139139

140140
return;
141141
}
142142

143-
$this->fail('CouldNotSendNotification exception was not raised');
143+
$this->fail('CouldNotSendMobilyWsNotification exception was not raised');
144144
}
145145

146146
/** @test */

tests/ConfigTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace NotificationChannels\MobilyWs\Test;
44

5-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
5+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
66
use NotificationChannels\MobilyWs\MobilyWsConfig;
77

88
class ConfigTest extends TestCase
@@ -62,7 +62,7 @@ public function it_throws_an_exception_when_authentication_method_is_not_set()
6262
try {
6363
$configArray = $this->getConfigs(['authentication' => null]);
6464
$mobilyWsConfig = new MobilyWsConfig($configArray);
65-
} catch (CouldNotSendNotification $e) {
65+
} catch (CouldNotSendMobilyWsNotification $e) {
6666
$this->assertEquals(
6767
$e->getMessage(),
6868
"Please set the authentication method in the mobilyws config file"
@@ -145,7 +145,7 @@ public function it_throws_an_exception_when_the_authentication_method_is_not_sup
145145
try {
146146
$configArray = $this->getConfigs(['authentication' => 'unsupportedMethod']);
147147
$mobilyWsConfig = new MobilyWsConfig($configArray);
148-
} catch (CouldNotSendNotification $e) {
148+
} catch (CouldNotSendMobilyWsNotification $e) {
149149
$this->assertEquals(
150150
$e->getMessage(),
151151
"Method unsupportedMethod is not supported. Please choose from: (apiKey, password, auto)"
@@ -168,7 +168,7 @@ public function it_throws_an_exception_when_no_credentials_are_provided()
168168
]);
169169

170170
$mobilyWsConfig = new MobilyWsConfig($configArray);
171-
} catch (CouldNotSendNotification $e) {
171+
} catch (CouldNotSendMobilyWsNotification $e) {
172172
$this->assertEquals(
173173
$e->getMessage(),
174174
"No credentials were provided. Please set your (mobile/password) or apiKey in the config file"
@@ -190,7 +190,7 @@ public function it_throws_an_exception_when_credentials_are_missing_password()
190190
]);
191191

192192
$mobilyWsConfig = new MobilyWsConfig($configArray);
193-
} catch (CouldNotSendNotification $e) {
193+
} catch (CouldNotSendMobilyWsNotification $e) {
194194
$this->assertEquals(
195195
$e->getMessage(),
196196
"No credentials were provided. Please set your (mobile/password) or apiKey in the config file"

tests/MessageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace NotificationChannels\MobilyWs\Test;
44

55
use Carbon\Carbon;
6-
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendNotification;
6+
use NotificationChannels\MobilyWs\Exceptions\CouldNotSendMobilyWsNotification;
77
use NotificationChannels\MobilyWs\MobilyWsMessage;
88

99
class MessageTest extends TestCase
@@ -88,7 +88,7 @@ public function it_throw_an_exception_when_given_invalid_time()
8888

8989
try {
9090
$message->time(['invalid time format']);
91-
} catch (CouldNotSendNotification $exception) {
91+
} catch (CouldNotSendMobilyWsNotification $exception) {
9292
$this->assertContains(
9393
"Time must be a timestamp or an object implementing DateTimeInterface. array is given",
9494
$exception->getMessage()

0 commit comments

Comments
 (0)