apply PSR-12 rules

This commit is contained in:
Daniel Seifert 2022-07-13 10:41:23 +02:00
parent fd8a3c93ad
commit 2acb1c9fb6
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
40 changed files with 213 additions and 198 deletions

13
.php-cs-fixer.php Normal file
View File

@ -0,0 +1,13 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP70Migration' => true,
'@PSR12' => true
])
->setFinder($finder)
;

View File

@ -18,7 +18,7 @@ abstract class ApiTestCase extends TestCase
* @return mixed
* @throws ReflectionException
*/
public function callMethod(object $object, string $methodName, array $arguments = array())
public function callMethod(object $object, string $methodName, array $arguments = [])
{
$class = new ReflectionClass($object);
$method = $class->getMethod($methodName);

View File

@ -72,8 +72,7 @@ abstract class AbstractResponse extends ApiTestCase
"contentCategory" => "informational",
"messageContent" => "fixture",
"senderAddressType" => "international",
]
,
],
$this->callMethod(
$response,
'getContent'

View File

@ -71,7 +71,9 @@ class Client
{
$options['headers']['Authorization'] = 'Bearer '.$this->accessToken;
if ($this->hasLogger()) $this->getLogger()->debug('request '.$url, $options);
if ($this->hasLogger()) {
$this->getLogger()->debug('request '.$url, $options);
}
$response = $this->requestClient->request(
$method,
@ -81,7 +83,9 @@ class Client
if ($response->getStatusCode() != 200) {
$message = sprintf(ExceptionMessages::NOK_REQUEST_RETURN, $url, $response->getStatusCode());
if ($this->hasLogger()) $this->getLogger()->error($message);
if ($this->hasLogger()) {
$this->getLogger()->error($message);
}
throw new ApiException($message);
}

View File

@ -19,5 +19,4 @@ namespace D3\LinkmobilityClient\Exceptions;
class ApiException extends LinkmobilityException
{
}

View File

@ -17,11 +17,11 @@ namespace D3\LinkmobilityClient\Exceptions;
class ExceptionMessages
{
const INVALID_SENDER = 'invalid sender phone number';
public const INVALID_SENDER = 'invalid sender phone number';
const NOK_REQUEST_RETURN = 'request %1$s returns status code %2$s';
public const NOK_REQUEST_RETURN = 'request %1$s returns status code %2$s';
const INVALID_RECIPIENT_PHONE = 'invalid recipient phone number';
public const INVALID_RECIPIENT_PHONE = 'invalid recipient phone number';
const NOT_A_MOBILE_NUMBER = 'not a mobile number';
public const NOT_A_MOBILE_NUMBER = 'not a mobile number';
}

View File

@ -21,5 +21,4 @@ use Exception;
class LinkmobilityException extends Exception
{
}

View File

@ -19,5 +19,4 @@ namespace D3\LinkmobilityClient\Exceptions;
class RecipientException extends LinkmobilityException
{
}

View File

@ -77,7 +77,6 @@ class RecipientsList implements RecipientsListInterface, Iterator
}
$this->recipients[ md5(serialize($recipient)) ] = $recipient;
} catch (NumberParseException $e) {
if ($this->getClient()->hasLogger()) {
$this->getClient()->getLogger()->info($e->getMessage());

View File

@ -25,24 +25,24 @@ use D3\LinkmobilityClient\Response\ResponseInterface as LMResponseInterface;
interface RequestInterface
{
const METHOD_GET = 'GET';
const METHOD_POST = 'POST';
const METHOD_PUT = 'PUT';
const METHOD_PATCH = 'PATCH';
const METHOD_DELETE = 'DELETE';
public const METHOD_GET = 'GET';
public const METHOD_POST = 'POST';
public const METHOD_PUT = 'PUT';
public const METHOD_PATCH = 'PATCH';
public const METHOD_DELETE = 'DELETE';
const CONTENTTYPE_JSON = 'application/json';
public const CONTENTTYPE_JSON = 'application/json';
const CONTENTCATEGORY_INFORMATIONAL = 'informational';
const CONTENTCATEGORY_ADVERTISEMENT = 'advertisement';
public const CONTENTCATEGORY_INFORMATIONAL = 'informational';
public const CONTENTCATEGORY_ADVERTISEMENT = 'advertisement';
const MESSAGETYPE_DEFAULT = 'default';
const MESSAGETYPE_VOICE = 'voice';
public const MESSAGETYPE_DEFAULT = 'default';
public const MESSAGETYPE_VOICE = 'voice';
const SENDERADDRESSTYPE_NATIONAL = 'national';
const SENDERADDRESSTYPE_INTERNATIONAL = 'international';
const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
public const SENDERADDRESSTYPE_NATIONAL = 'national';
public const SENDERADDRESSTYPE_INTERNATIONAL = 'international';
public const SENDERADDRESSTYPE_ALPHANUMERIC = 'alphanumeric';
public const SENDERADDRESSTYPE_SHORTCODE = 'shortcode';
public function __construct(SmsMessageInterface $message, Client $client);

View File

@ -1,16 +1,17 @@
<?php
declare(strict_types=1);
namespace D3\LinkmobilityClient\Response;
abstract class Response implements ResponseInterface
{
const STATUSCODE = 'statusCode';
const STATUSMESSAGE = 'statusMessage';
const CLIENTMESSAGEID = 'clientMessageId';
const TRANSFERID = 'transferId';
const SMSCOUNT = 'smsCount';
public const STATUSCODE = 'statusCode';
public const STATUSMESSAGE = 'statusMessage';
public const CLIENTMESSAGEID = 'clientMessageId';
public const TRANSFERID = 'transferId';
public const SMSCOUNT = 'smsCount';
/**
* @var \Psr\Http\Message\ResponseInterface

View File

@ -27,12 +27,12 @@ class RequestFactory
/**
* @deprecated is SmsLength constant from version 2.1
*/
const GSM_7BIT = '7-bit';
public const GSM_7BIT = '7-bit';
/**
* @deprecated is SmsLength constant from version 2.1
*/
const GSM_UCS2 = 'ucs-2';
public const GSM_UCS2 = 'ucs-2';
protected $message;
protected $client;

View File

@ -17,4 +17,6 @@ namespace D3\LinkmobilityClient\SMS;
use D3\LinkmobilityClient\Request\RequestInterface;
interface SmsRequestInterface extends RequestInterface {}
interface SmsRequestInterface extends RequestInterface
{
}