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

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

@ -18,7 +18,7 @@ abstract class ApiTestCase extends TestCase
* @return mixed * @return mixed
* @throws ReflectionException * @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); $class = new ReflectionClass($object);
$method = $class->getMethod($methodName); $method = $class->getMethod($methodName);

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

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

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

@ -17,11 +17,11 @@ namespace D3\LinkmobilityClient\Exceptions;
class ExceptionMessages 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';
} }

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

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

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

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

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

@ -27,12 +27,12 @@ class RequestFactory
/** /**
* @deprecated is SmsLength constant from version 2.1 * @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 * @deprecated is SmsLength constant from version 2.1
*/ */
const GSM_UCS2 = 'ucs-2'; public const GSM_UCS2 = 'ucs-2';
protected $message; protected $message;
protected $client; protected $client;

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