1
1
<?php
2
2
3
+ declare (strict_types=1 );
4
+
3
5
namespace NotificationChannels \Cmsms ;
4
6
5
- use GuzzleHttp \ Client as GuzzleClient ;
7
+ use SimpleXMLElement ;
6
8
use Illuminate \Support \Arr ;
9
+ use GuzzleHttp \Client as GuzzleClient ;
7
10
use NotificationChannels \Cmsms \Exceptions \CouldNotSendNotification ;
8
- use SimpleXMLElement ;
9
11
10
12
class CmsmsClient
11
13
{
@@ -21,7 +23,7 @@ class CmsmsClient
21
23
* @param GuzzleClient $client
22
24
* @param string $productToken
23
25
*/
24
- public function __construct (GuzzleClient $ client , $ productToken )
26
+ public function __construct (GuzzleClient $ client , string $ productToken )
25
27
{
26
28
$ this ->client = $ client ;
27
29
$ this ->productToken = $ productToken ;
@@ -32,7 +34,7 @@ public function __construct(GuzzleClient $client, $productToken)
32
34
* @param string $recipient
33
35
* @throws CouldNotSendNotification
34
36
*/
35
- public function send (CmsmsMessage $ message , $ recipient )
37
+ public function send (CmsmsMessage $ message , string $ recipient )
36
38
{
37
39
if (is_null (Arr::get ($ message ->toXmlArray (), 'FROM ' ))) {
38
40
$ message ->originator (config ('services.cmsms.originator ' ));
@@ -58,20 +60,20 @@ public function send(CmsmsMessage $message, $recipient)
58
60
* @param string $recipient
59
61
* @return string
60
62
*/
61
- public function buildMessageXml (CmsmsMessage $ message , $ recipient )
63
+ public function buildMessageXml (CmsmsMessage $ message , string $ recipient ): string
62
64
{
63
65
$ xml = new SimpleXMLElement ('<MESSAGES/> ' );
64
66
65
67
$ xml ->addChild ('AUTHENTICATION ' )
66
68
->addChild ('PRODUCTTOKEN ' , $ this ->productToken );
67
69
68
70
if ($ tariff = $ message ->getTariff ()) {
69
- $ xml ->addChild ('TARIFF ' , $ tariff );
71
+ $ xml ->addChild ('TARIFF ' , ( string ) $ tariff );
70
72
}
71
73
72
74
$ msg = $ xml ->addChild ('MSG ' );
73
75
foreach ($ message ->toXmlArray () as $ name => $ value ) {
74
- $ msg ->addChild ($ name , $ value );
76
+ $ msg ->addChild ($ name , ( string ) $ value );
75
77
}
76
78
$ msg ->addChild ('TO ' , $ recipient );
77
79
0 commit comments