fix codestyle

This commit is contained in:
osaajani 2020-06-23 21:06:13 +02:00
parent 350dbb5b59
commit adef27f862
37 changed files with 556 additions and 488 deletions

View file

@ -14,7 +14,7 @@ namespace adapters;
use Ovh\Api;
/**
* OVH SMS service with a shortcode allowing responses
* OVH SMS service with a shortcode allowing responses.
*/
class OvhSmsShortcodeAdapter implements AdapterInterface
{
@ -56,9 +56,9 @@ namespace adapters;
/**
* Uniq name of the adapter
* It should be the classname of the adapter un snakecase
* It should be the classname of the adapter un snakecase.
*/
public static function meta_uid() : string
public static function meta_uid(): string
{
return 'ovh_sms_shortcode_adapter';
}
@ -151,7 +151,7 @@ namespace adapters;
{
return true;
}
/**
* Does the implemented service support reception callback.
*/
@ -160,7 +160,6 @@ namespace adapters;
return false;
}
/**
* Method called to send a SMS to a number.
*
@ -169,10 +168,10 @@ namespace adapters;
* @param bool $flash : Is the SMS a Flash SMS
*
* @return array : [
* bool 'error' => false if no error, true else
* ?string 'error_message' => null if no error, else error message
* ?string 'uid' => Uid of the sms created on success
* ]
* bool 'error' => false if no error, true else
* ?string 'error_message' => null if no error, else error message
* ?string 'uid' => Uid of the sms created on success
* ]
*/
public function send(string $destination, string $text, bool $flash = false)
{
@ -206,6 +205,7 @@ namespace adapters;
{
$response['error'] = true;
$response['error_message'] = 'Invalid receiver';
return $response;
}
@ -214,16 +214,19 @@ namespace adapters;
{
$response['error'] = true;
$response['error_message'] = 'Cannot retrieve uid.';
return $response;
}
$response['uid'] = $uid;
return $response;
}
catch (\Throwable $t)
{
$response['error'] = true;
$response['error_message'] = $t->getMessage();
return $response;
}
}
@ -232,10 +235,10 @@ namespace adapters;
* Method called to read SMSs of the number.
*
* @return array : [
* bool 'error' => false if no error, true else
* ?string 'error_message' => null if no error, else error message
* array 'sms' => Array of the sms reads
* ]
* bool 'error' => false if no error, true else
* ?string 'error_message' => null if no error, else error message
* array 'sms' => Array of the sms reads
* ]
*/
public function read(): array
{
@ -288,6 +291,7 @@ namespace adapters;
{
$response['error'] = true;
$response['error_message'] = $t->getMessage();
return $response;
}
}
@ -303,7 +307,7 @@ namespace adapters;
try
{
$success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11)))
{
return false;
@ -312,9 +316,8 @@ namespace adapters;
//Check service name
$endpoint = '/sms/' . $this->datas['service_name'];
$response = $this->api->get($endpoint);
$success = $success && (bool) $response;
return $success;
return $success && (bool) $response;
}
catch (\Throwable $t)
{
@ -356,23 +359,22 @@ namespace adapters;
return ['uid' => $uid, 'status' => $status];
}
/**
* Method called on reception of a sms notification.
*
* @return array : [
* bool 'error' => false on success, true on error
* ?string 'error_message' => null on success, error message else
* array 'sms' => array [
* string 'at' : Recepetion date format Y-m-d H:i:s,
* string 'text' : SMS body,
* string 'origin' : SMS sender,
* ]
* bool 'error' => false on success, true on error
* ?string 'error_message' => null on success, error message else
* array 'sms' => array [
* string 'at' : Recepetion date format Y-m-d H:i:s,
* string 'text' : SMS body,
* string 'origin' : SMS sender,
* ]
*
* ]
*/
public static function reception_callback() : array
public static function reception_callback(): array
{
return [];
}