Skip to content

Commit

Permalink
Merge pull request #18 from Mostafa7000/master
Browse files Browse the repository at this point in the history
FIX: avoid using current() on objects as it's deprecated
  • Loading branch information
ahmadalfy authored Oct 7, 2024
2 parents d461218 + 0bd37c5 commit 382f5cc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
25 changes: 12 additions & 13 deletions src/Drivers/VectoryLinkDriver.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace RobustTools\Resala\Drivers;

use RobustTools\Resala\Abstracts\Driver;
Expand Down Expand Up @@ -52,29 +53,27 @@ public function message(string $message): string

public function send(): SMSDriverResponseInterface
{
$response = HTTP::get($this->endPoint, $this->headers(), $this->payload());
$response = HTTP::post($this->endPoint, $this->headers(), $this->payload());

return new VectoryLinkResponse($response);
}

protected function payload(): array
protected function payload(): string
{
return
[
"SMSText" => $this->message,
"SMSReceiver" => $this->recipients,
"SMSSender" => $this->senderName,
'SMSLang' => $this->lang,
'UserName' => $this->username,
'Password' => $this->password
];
return http_build_query([
"SMSText" => $this->message,
"SMSReceiver" => $this->recipients,
"SMSSender" => $this->senderName,
'SMSLang' => $this->lang,
'UserName' => $this->username,
'Password' => $this->password
]);
}

protected function headers(): array
{
return [
'Content-Type' => 'text/xml; charset=utf-8',
'Content-Length' => 0
'Content-Type' => 'application/x-www-form-urlencoded'
];
}
}
2 changes: 1 addition & 1 deletion src/Response/VectoryLinkResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class VectoryLinkResponse implements SMSDriverResponseInterface
public function __construct(ResponseInterface $response)
{
$this->response = new SimpleXMLElement($response->getBody());
$this->status = (int) current($this->response);
$this->status = (int) current(get_mangled_object_vars($this->response));
}

public function success(): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Support/ConfigRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function offsetExists($offset): bool
return $this->has($offset);
}

public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->get($offset);
}
Expand Down

0 comments on commit 382f5cc

Please sign in to comment.