Skip to content

Commit d31b371

Browse files
committed
fixed throwed exception
1 parent 8a86a18 commit d31b371

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

src/Adapter/AdapterAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tartan\IranianSms\Adapter;
44

5-
use Exception;
5+
use Tartan\IranianSms\Exception;
66

77
abstract class AdapterAbstract {
88

src/Adapter/MehrAfraz.php

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

33
namespace Tartan\IranianSms\Adapter;
44

5-
class MehrAfraz extends AdapterAbstract implements AdapterInterface {
5+
use SoapClient;
6+
use Tartan\IranianSms\Exception;
7+
8+
class MehrAfraz extends AdapterAbstract implements AdapterInterface
9+
{
610

711
public $gateway_url;
812

@@ -12,65 +16,61 @@ class MehrAfraz extends AdapterAbstract implements AdapterInterface {
1216
];
1317

1418
public static $status_real = [
15-
0 => 'SENDING',
16-
1 => 'SERVICE_DELIVERED',
17-
2 => 'DELIVERED',
18-
3 => 'FAILED',
19-
4 => 'BLACKLIST',
20-
5 => 'NOT_EXPERT',
21-
6 => 'CANCELED',
22-
7 => 'UNKNOWN_DESTINATION',
23-
8 => 'BTS_SENT',
19+
0 => 'SENDING',
20+
1 => 'SERVICE_DELIVERED',
21+
2 => 'DELIVERED',
22+
3 => 'FAILED',
23+
4 => 'BLACKLIST',
24+
5 => 'NOT_EXPERT',
25+
6 => 'CANCELED',
26+
7 => 'UNKNOWN_DESTINATION',
27+
8 => 'BTS_SENT',
2428
12 => 'NOT_SENT_OPERATOR',
2529
16 => 'BTS_ERROR',
2630
];
2731

28-
public function __construct() {
29-
$this->gateway_url = config('iranian_sms.mehrafraz.gateway');
32+
public function __construct()
33+
{
34+
$this->gateway_url = config('iranian_sms.mehrafraz.gateway');
3035
$this->credential['username'] = config('iranian_sms.mehrafraz.username');
3136
$this->credential['password'] = config('iranian_sms.mehrafraz.password');
3237
}
3338

34-
public function send(String $number,String $message) {
39+
public function send(String $number, String $message)
40+
{
3541

3642
$number = $this->filterNumber($number);
3743

3844
$parameters = [
39-
'cUserName' => $this->credential['username'],
40-
'cPassword' => $this->credential['password'],
41-
'cBody' => $message,
42-
'cSmsnumber' => $number,
43-
'cGetid' => time(),
44-
'nCMessage' => '1',
45-
'nTypeSent' => '1',
45+
'cUserName' => $this->credential['username'],
46+
'cPassword' => $this->credential['password'],
47+
'cBody' => $message,
48+
'cSmsnumber' => $number,
49+
'cGetid' => time(),
50+
'nCMessage' => '1',
51+
'nTypeSent' => '1',
4652
'm_SchedulDate' => '',
47-
'cDomainname' => $this->credential['username'],
48-
'nSpeedsms' => '0',
49-
'nPeriodmin' => '0',
50-
'cstarttime' => '',
51-
'cEndTime' => '',
53+
'cDomainname' => $this->credential['username'],
54+
'nSpeedsms' => '0',
55+
'nPeriodmin' => '0',
56+
'cstarttime' => '',
57+
'cEndTime' => '',
5258
];
5359

54-
try {
55-
$soapParams = [];
56-
$soapParams['xml_encoding'] = "UTF-8";
57-
$soapParams['soap_defencoding'] = "UTF-8";
58-
$soapParams['decode_utf8'] = false;
59-
$soapParams['exceptions'] = 1;
60-
$soapClient = @new \SoapClient($this->gateway_url, $soapParams);
61-
$result = $soapClient->SendSms($parameters);
62-
} catch (SoapFault $client) {
63-
//
64-
} catch (Exception $e) {
65-
//
66-
}
60+
$soapParams = [];
61+
$soapParams['xml_encoding'] = "UTF-8";
62+
$soapParams['soap_defencoding'] = "UTF-8";
63+
$soapParams['decode_utf8'] = false;
64+
$soapParams['exceptions'] = 1;
65+
$soapClient = new SoapClient($this->gateway_url, $soapParams);
66+
$result = $soapClient->SendSms($parameters);
6767

6868

6969
if (($result->SendSmsResult && $result->SendSmsResult > 1000)) {
7070
return $result->SendSmsResult;
7171
}
7272

73-
throw new \Exception("SMS cannot be send!");
73+
throw new Exception("SMS cannot be send!");
7474
}
7575

7676
}

src/Adapter/ParsaSms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Tartan\IranianSms\Adapter;
44

55
use Ghasedak\GhasedakApi;
6-
use Exception;
6+
use Tartan\IranianSms\Exception;
77

88
class ParsaSms extends AdapterAbstract implements AdapterInterface
99
{

src/Adapter/Slack.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Tartan\IranianSms\Adapter;
44

5+
use Tartan\IranianSms\Exception;
6+
57
class Slack extends AdapterAbstract implements AdapterInterface
68
{
79
public $url;

0 commit comments

Comments
 (0)