apply PSR-12 rules

Cette révision appartient à :
Daniel Seifert 2022-07-13 10:41:23 +02:00
Parent fd8a3c93ad
révision 2acb1c9fb6
Signé par: DanielS
ID de la clé GPG: 8A7C4C6ED1915C6F
40 fichiers modifiés avec 213 ajouts et 198 suppressions

13
.php-cs-fixer.php Fichier normal
Voir le fichier

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

Voir le fichier

@ -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);

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests;
@ -44,7 +44,7 @@ class ClientTest extends ApiTestCase
/**
* @return void
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\RecipientsList;
@ -42,7 +42,7 @@ class RecipientsListTest extends ApiTestCase
/**
* @return void
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();
@ -164,11 +164,11 @@ class RecipientsListTest extends ApiTestCase
->getMock();
if ($unparsable) {
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
} else {
$phoneNumberUtilMock->method( 'parse' )->willReturn( new PhoneNumber() );
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber());
}
$phoneNumberUtilMock->method( 'isValidNumber' )->willReturn( !$invalidNumber );
$phoneNumberUtilMock->method('isValidNumber')->willReturn(!$invalidNumber);
$phoneNumberUtilMock->method('getNumberType')->willReturn($invalidNumberType ? PhoneNumberType::FIXED_LINE : PhoneNumberType::MOBILE);
/** @var Recipient|MockObject $recipientMock */
@ -435,32 +435,32 @@ class RecipientsListTest extends ApiTestCase
protected function addRecipientFixture(): array
{
/** @var Recipient|MockObject $recipientMock */
$recipientMock = $this->getMockBuilder( Recipient::class )
->onlyMethods( [
$recipientMock = $this->getMockBuilder(Recipient::class)
->onlyMethods([
'get',
'getCountryCode'
] )
->setConstructorArgs( [
])
->setConstructorArgs([
$this->phoneNumberFixture,
$this->phoneCountryFixture
] )
])
->getMock();
$recipientMock->method( 'get' )->willReturn( $this->phoneNumberFixture );
$recipientMock->method( 'getCountryCode' )->willReturn( $this->phoneCountryFixture );
$recipientMock->method('get')->willReturn($this->phoneNumberFixture);
$recipientMock->method('getCountryCode')->willReturn($this->phoneCountryFixture);
/** @var Recipient|MockObject $recipientMock2 */
$recipientMock2 = $this->getMockBuilder( Recipient::class )
->onlyMethods( [
$recipientMock2 = $this->getMockBuilder(Recipient::class)
->onlyMethods([
'get',
'getCountryCode'
] )
->setConstructorArgs( [
])
->setConstructorArgs([
$this->phoneNumberFixture,
$this->phoneCountryFixture
] )
])
->getMock();
$recipientMock2->method( 'get' )->willReturn( $this->phoneNumberFixture );
$recipientMock2->method( 'getCountryCode' )->willReturn( $this->phoneCountryFixture );
$recipientMock2->method('get')->willReturn($this->phoneNumberFixture);
$recipientMock2->method('getCountryCode')->willReturn($this->phoneCountryFixture);
$list = [
'fixture' => $recipientMock,
@ -475,4 +475,4 @@ class RecipientsListTest extends ApiTestCase
return $list;
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\Request;
@ -554,4 +554,4 @@ abstract class AbstractRequest extends ApiTestCase
$this->checkGetterSetter($clientMock, 'setClient', 'getClient');
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\Response;
@ -72,8 +72,7 @@ abstract class AbstractResponse extends ApiTestCase
"contentCategory" => "informational",
"messageContent" => "fixture",
"senderAddressType" => "international",
]
,
],
$this->callMethod(
$response,
'getContent'
@ -213,4 +212,4 @@ abstract class AbstractResponse extends ApiTestCase
'not successful'=> [false, 'fixtureMessage']
];
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\SMS;
@ -25,4 +25,4 @@ class BinaryRequestTest extends AbstractRequest
{
protected $testClassName = BinaryRequest::class;
protected $messageClassName = SmsBinaryMessage::class;
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\SMS;
@ -132,4 +132,4 @@ class RequestFactoryTest extends ApiTestCase
)
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\SMS;
@ -23,4 +23,4 @@ use D3\LinkmobilityClient\Tests\Response\AbstractResponse;
class ResponseTest extends AbstractResponse
{
protected $testClassName = Response::class;
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\SMS;
@ -25,4 +25,4 @@ class TextRequestTest extends AbstractRequest
{
protected $testClassName = TextRequest::class;
protected $messageClassName = SmsTextMessage::class;
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests;
@ -28,7 +28,7 @@ class UrlTest extends ApiTestCase
/**
* @return void
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject;
@ -38,7 +38,7 @@ class RecipientTest extends ApiTestCase
* @return void
* @throws NumberParseException
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();
@ -116,9 +116,9 @@ class RecipientTest extends ApiTestCase
->disableOriginalConstructor()
->getMock();
if ($number === 'abc') {
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
} else {
$phoneNumberUtilMock->method( 'parse' )->willReturn( new PhoneNumber() );
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber());
}
$phoneNumberUtilMock->method('format')->willReturn($number);
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
@ -161,4 +161,4 @@ class RecipientTest extends ApiTestCase
)
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject;
@ -40,11 +40,11 @@ class SenderTest extends ApiTestCase
* @throws NumberParseException
* @throws RecipientException
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();
$this->sender = new Sender( $this->phoneNumberFixture, $this->phoneCountryFixture);
$this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture);
}
/**
@ -111,9 +111,9 @@ class SenderTest extends ApiTestCase
->disableOriginalConstructor()
->getMock();
if ($number === 'abc') {
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
} else {
$phoneNumberUtilMock->method( 'parse' )->willReturn( new PhoneNumber() );
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber());
}
$phoneNumberUtilMock->method('format')->willReturn($number);
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
@ -156,4 +156,4 @@ class SenderTest extends ApiTestCase
)
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject;
@ -34,11 +34,11 @@ class SmsBinaryMessageTest extends ApiTestCase
/**
* @return void
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();
$this->message = new SmsBinaryMessage( $this->messageFixture);
$this->message = new SmsBinaryMessage($this->messageFixture);
}
/**
@ -100,9 +100,9 @@ class SmsBinaryMessageTest extends ApiTestCase
->onlyMethods(['validate'])
->getMock();
if ($valid) {
$smsLengthMock->expects( $this->never() )->method( 'validate' )->willReturn( true );
$smsLengthMock->expects($this->never())->method('validate')->willReturn(true);
} else {
$smsLengthMock->expects( $this->atLeastOnce() )->method( 'validate' )->willThrowException(new \Phlib\SmsLength\Exception\InvalidArgumentException());
$smsLengthMock->expects($this->atLeastOnce())->method('validate')->willThrowException(new \Phlib\SmsLength\Exception\InvalidArgumentException());
}
/** @var SmsBinaryMessage|MockObject $message */
@ -240,4 +240,4 @@ class SmsBinaryMessageTest extends ApiTestCase
)
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject;
@ -33,11 +33,11 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
/**
* @return void
*/
public function setUp():void
public function setUp(): void
{
parent::setUp();
$this->message = new SmsTextMessage( $this->messageFixture);
$this->message = new SmsTextMessage($this->messageFixture);
}
/**
@ -89,9 +89,9 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
->onlyMethods(['validate'])
->getMock();
if ($valid) {
$smsLengthMock->expects( $this->never() )->method( 'validate' )->willReturn( true );
$smsLengthMock->expects($this->never())->method('validate')->willReturn(true);
} else {
$smsLengthMock->expects( $this->atLeastOnce() )->method( 'validate' )->willThrowException(new InvalidArgumentException());
$smsLengthMock->expects($this->atLeastOnce())->method('validate')->willThrowException(new InvalidArgumentException());
}
/** @var SmsTextMessage|MockObject $message */
@ -112,4 +112,4 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
)
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient;
@ -38,7 +38,7 @@ class Client
{
$this->accessToken = $accessToken;
$this->apiUrl = $apiUrl ?: new Url();
$this->requestClient = $client ?: new \GuzzleHttp\Client( [ 'base_uri' => $this->apiUrl->getBaseUri() ] );
$this->requestClient = $client ?: new \GuzzleHttp\Client([ 'base_uri' => $this->apiUrl->getBaseUri() ]);
}
/**
@ -49,7 +49,7 @@ class Client
* @throws GuzzleException
* @throws InvalidArgumentException
*/
public function request(RequestInterface $request) : Response\ResponseInterface
public function request(RequestInterface $request): Response\ResponseInterface
{
$request->validate();
@ -67,11 +67,13 @@ class Client
* @throws ApiException
* @throws GuzzleException
*/
protected function rawRequest( $url, string $method = RequestInterface::METHOD_GET, array $options = []): ResponseInterface
protected function rawRequest($url, string $method = RequestInterface::METHOD_GET, array $options = []): ResponseInterface
{
$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);
}
@ -98,7 +102,7 @@ class Client
*
* @return Client
*/
public function setLogger(LoggerInterface $logger ) : Client
public function setLogger(LoggerInterface $logger): Client
{
$this->logger = $logger;
@ -108,7 +112,7 @@ class Client
/**
* @return bool
*/
public function hasLogger() : bool
public function hasLogger(): bool
{
return $this->logger instanceof LoggerInterface;
}
@ -120,4 +124,4 @@ class Client
{
return $this->hasLogger() ? $this->logger : null;
}
}
}

Voir le fichier

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

Voir le fichier

@ -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';
}

Voir le fichier

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

Voir le fichier

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

Voir le fichier

@ -38,7 +38,7 @@ class RecipientsList implements RecipientsListInterface, Iterator
*/
private $recipients = [];
public function __construct( Client $client )
public function __construct(Client $client)
{
$this->setClient($client);
}
@ -56,28 +56,27 @@ class RecipientsList implements RecipientsListInterface, Iterator
*
* @return RecipientsListInterface
*/
public function add(Recipient $recipient) : RecipientsListInterface
public function add(Recipient $recipient): RecipientsListInterface
{
$phoneUtil = $this->getPhoneNumberUtil();
try {
$phoneNumber = $phoneUtil->parse( $recipient->get(), $recipient->getCountryCode() );
$phoneNumber = $phoneUtil->parse($recipient->get(), $recipient->getCountryCode());
if ( false === $phoneUtil->isValidNumber( $phoneNumber ) ) {
throw new RecipientException( ExceptionMessages::INVALID_RECIPIENT_PHONE );
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
throw new RecipientException(ExceptionMessages::INVALID_RECIPIENT_PHONE);
} elseif (
false === in_array(
$phoneUtil->getNumberType( $phoneNumber ),
$phoneUtil->getNumberType($phoneNumber),
[
PhoneNumberType::MOBILE,
PhoneNumberType::FIXED_LINE_OR_MOBILE
]
)
) {
throw new RecipientException( ExceptionMessages::NOT_A_MOBILE_NUMBER );
throw new RecipientException(ExceptionMessages::NOT_A_MOBILE_NUMBER);
}
$this->recipients[ md5( serialize( $recipient ) ) ] = $recipient;
$this->recipients[ md5(serialize($recipient)) ] = $recipient;
} catch (NumberParseException $e) {
if ($this->getClient()->hasLogger()) {
$this->getClient()->getLogger()->info($e->getMessage());
@ -87,21 +86,21 @@ class RecipientsList implements RecipientsListInterface, Iterator
$this->getClient()->getLogger()->info($e->getMessage());
}
}
return $this;
}
/**
* @return RecipientsListInterface
*/
public function clearRecipents() : RecipientsListInterface
public function clearRecipents(): RecipientsListInterface
{
$this->recipients = [];
return $this;
}
public function getRecipients() : array
public function getRecipients(): array
{
return array_values(
array_map(
@ -116,7 +115,7 @@ class RecipientsList implements RecipientsListInterface, Iterator
/**
* @return array
*/
public function getRecipientsList() : array
public function getRecipientsList(): array
{
return $this->recipients;
}
@ -165,10 +164,10 @@ class RecipientsList implements RecipientsListInterface, Iterator
*
* @return RecipientsList
*/
public function setClient( Client $client ): RecipientsList
public function setClient(Client $client): RecipientsList
{
$this->client = $client;
return $this;
}
}
}

Voir le fichier

@ -24,9 +24,9 @@ interface RecipientsListInterface
{
public function __construct(Client $client);
public function add(Recipient $recipient) : RecipientsListInterface;
public function add(Recipient $recipient): RecipientsListInterface;
public function clearRecipents() : RecipientsListInterface;
public function clearRecipents(): RecipientsListInterface;
public function getRecipients() : array;
}
public function getRecipients(): array;
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\Request;
@ -118,7 +118,7 @@ abstract class Request implements RequestInterface
public function __construct(SmsMessageInterface $message, Client $client)
{
$this->recipientsList = new RecipientsList($client);
$this->setMessage( $message );
$this->setMessage($message);
$this->setClient($client);
return $this;
@ -129,30 +129,30 @@ abstract class Request implements RequestInterface
*/
public function validate()
{
Assert::that( $this->getMethod() )->choice( self::getMethods() );
Assert::that( $this->getUri() )->string()->startsWith( '/' );
Assert::that($this->getMethod())->choice(self::getMethods());
Assert::that($this->getUri())->string()->startsWith('/');
Assert::that($this->getBody())->isArray();
Assert::that($this->getResponseClass())->implementsInterface(ResponseInterface::class);
Assert::that($this->getOptions())->isArray();
Assert::that( $this->getRecipientsList() )->isInstanceOf(RecipientsList::class)->notEmpty();
Assert::that( $this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient');
Assert::thatAll( $this->getRecipientsList() )->isInstanceOf( Recipient::class )->notEmpty();
Assert::that($this->getRecipientsList())->isInstanceOf(RecipientsList::class)->notEmpty();
Assert::that($this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient');
Assert::thatAll($this->getRecipientsList())->isInstanceOf(Recipient::class)->notEmpty();
// optional properties
Assert::thatNullOr( $this->getClientMessageId() )->string();
Assert::thatNullOr( $this->getContentCategory() )->choice(self::getContentCategories());
Assert::thatNullOr( $this->getNotificationCallbackUrl() )->url();
Assert::thatNullOr( $this->getPriority() )->integer();
Assert::thatNullOr( $this->doSendAsFlashSms() )->boolean();
Assert::thatNullOr( $this->getSenderAddress() )->isInstanceOf(Sender::class);
Assert::thatNullOr( $this->getSenderAddressType() )->choice(self::getSenderAddressTypes());
Assert::thatNullOr( $this->getTestMode() )->boolean();
Assert::thatNullOr( $this->getValidityPeriode() )->integer();
Assert::thatNullOr($this->getClientMessageId())->string();
Assert::thatNullOr($this->getContentCategory())->choice(self::getContentCategories());
Assert::thatNullOr($this->getNotificationCallbackUrl())->url();
Assert::thatNullOr($this->getPriority())->integer();
Assert::thatNullOr($this->doSendAsFlashSms())->boolean();
Assert::thatNullOr($this->getSenderAddress())->isInstanceOf(Sender::class);
Assert::thatNullOr($this->getSenderAddressType())->choice(self::getSenderAddressTypes());
Assert::thatNullOr($this->getTestMode())->boolean();
Assert::thatNullOr($this->getValidityPeriode())->integer();
}
public function getRawBody() : array
public function getRawBody(): array
{
return [
'clientMessageId' => $this->getClientMessageId(),
@ -174,9 +174,9 @@ abstract class Request implements RequestInterface
*/
public function getBody(): array
{
$body = array_filter( $this->getRawBody(), function( $elm ) {
return ! is_null( $elm );
} );
$body = array_filter($this->getRawBody(), function ($elm) {
return ! is_null($elm);
});
switch ($this->getContentType()) {
case RequestInterface::CONTENTTYPE_JSON:
@ -259,7 +259,7 @@ abstract class Request implements RequestInterface
return $this;
}
public function getContentType() : string
public function getContentType(): string
{
return $this->contentType;
}
@ -293,7 +293,7 @@ abstract class Request implements RequestInterface
return $this;
}
public function getContentCategory() : string
public function getContentCategory(): string
{
return $this->contentCategory;
}
@ -318,7 +318,7 @@ abstract class Request implements RequestInterface
return $this;
}
public function getTestMode() : bool
public function getTestMode(): bool
{
return $this->test;
}
@ -335,7 +335,7 @@ abstract class Request implements RequestInterface
return $this;
}
public function getMaxSmsPerMessage() : int
public function getMaxSmsPerMessage(): int
{
return $this->maxSmsPerMessage;
}
@ -352,7 +352,7 @@ abstract class Request implements RequestInterface
return $this;
}
public function getMessageType() : string
public function getMessageType(): string
{
return $this->messageType;
}
@ -400,7 +400,7 @@ abstract class Request implements RequestInterface
/**
* @return RecipientsListInterface
*/
public function getRecipientsList() : RecipientsListInterface
public function getRecipientsList(): RecipientsListInterface
{
return $this->recipientsList;
}
@ -420,7 +420,7 @@ abstract class Request implements RequestInterface
/**
* @return bool|null
*/
public function doSendAsFlashSms() : bool
public function doSendAsFlashSms(): bool
{
return $this->sendAsFlashSms;
}
@ -483,7 +483,7 @@ abstract class Request implements RequestInterface
*
* @return $this
*/
public function setValidityPeriode( int $validityPeriode): Request
public function setValidityPeriode(int $validityPeriode): Request
{
$this->validityPeriode = $validityPeriode;
@ -520,10 +520,10 @@ abstract class Request implements RequestInterface
/**
* @param Client $client
*/
public function setClient( Client $client ): Request
public function setClient(Client $client): Request
{
$this->client = $client;
return $this;
}
}
}

Voir le fichier

@ -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);
@ -53,28 +53,28 @@ interface RequestInterface
*
* @return string
*/
public function getMethod() : string;
public function getMethod(): string;
/**
* Must return the URI for the request with a leading slash, i.e. /messages.json
*
* @return string
*/
public function getUri() : string;
public function getUri(): string;
/**
* Must return the body which is being sent as json
*
* @return array
*/
public function getBody() : array;
public function getBody(): array;
/**
* Must return the class to where the response is handed over. It must implement the ResponseInterface
*
* @return string
*/
public function getResponseClass() : string;
public function getResponseClass(): string;
/**
* @param PsrResponseInterface $rawResponse
@ -88,7 +88,7 @@ interface RequestInterface
*
* @return array
*/
public function getOptions() : array;
public function getOptions(): array;
/**
* Must validate the input of the request
@ -98,4 +98,4 @@ interface RequestInterface
* @throws InvalidArgumentException
*/
public function validate();
}
}

Voir le fichier

@ -1,4 +1,5 @@
<?php
<?php
declare(strict_types=1);
@ -6,11 +7,11 @@ 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
@ -31,8 +32,8 @@ abstract class Response implements ResponseInterface
$this->rawResponse->getBody()->rewind();
$this->content = json_decode($this->rawResponse->getBody()->getContents(), true);
}
public function getRawResponse() : \Psr\Http\Message\ResponseInterface
public function getRawResponse(): \Psr\Http\Message\ResponseInterface
{
return $this->rawResponse;
}
@ -45,7 +46,7 @@ abstract class Response implements ResponseInterface
/**
* @return int
*/
public function getInternalStatus() : int
public function getInternalStatus(): int
{
return $this->getContent()[self::STATUSCODE];
}
@ -53,7 +54,7 @@ abstract class Response implements ResponseInterface
/**
* @return string
*/
public function getStatusMessage() : string
public function getStatusMessage(): string
{
return $this->getContent()[self::STATUSMESSAGE];
}
@ -77,7 +78,7 @@ abstract class Response implements ResponseInterface
/**
* @return string|null
*/
public function getSmsCount() : int
public function getSmsCount(): int
{
return $this->getContent()[self::SMSCOUNT];
}

Voir le fichier

@ -8,17 +8,17 @@ interface ResponseInterface
{
public function __construct(\Psr\Http\Message\ResponseInterface $rawResponse);
public function getRawResponse() : \Psr\Http\Message\ResponseInterface;
public function getRawResponse(): \Psr\Http\Message\ResponseInterface;
public function getInternalStatus() : int;
public function getInternalStatus(): int;
public function getStatusMessage() : string;
public function getStatusMessage(): string;
public function getClientMessageId();
public function getTransferId();
public function getSmsCount() : int;
public function getSmsCount(): int;
public function isSuccessful(): bool;

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS;
@ -32,7 +32,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
return '/rest/smsmessaging/binary';
}
public function getRawBody() : array
public function getRawBody(): array
{
return array_merge(
parent::getRawBody(),
@ -49,7 +49,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
{
parent::validate();
Assert::thatNullOr( $this->getMessage() )->isInstanceOf(SmsBinaryMessage::class);
Assert::thatNullOr($this->getMessage())->isInstanceOf(SmsBinaryMessage::class);
}
/**
@ -59,4 +59,4 @@ class BinaryRequest extends Request implements SmsRequestInterface
{
return Response::class;
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS;
@ -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;
@ -46,7 +46,7 @@ class RequestFactory
/**
* @return SmsRequestInterface
*/
public function getSmsRequest() : SmsRequestInterface
public function getSmsRequest(): SmsRequestInterface
{
if ($this->getSmsLength()->getEncoding() === self::GSM_7BIT) {
$message = new SmsTextMessage($this->message);
@ -64,4 +64,4 @@ class RequestFactory
{
return new SmsLength($this->message);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS;
@ -21,5 +21,5 @@ interface RequestFactoryInterface
{
public function __construct($message);
public function getRequest() : SmsRequestInterface;
}
public function getRequest(): SmsRequestInterface;
}

Voir le fichier

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

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS;
@ -39,7 +39,7 @@ class TextRequest extends Request implements SmsRequestInterface
{
parent::validate();
Assert::thatNullOr( $this->getMessage() )->isInstanceOf(SmsTextMessage::class);
Assert::thatNullOr($this->getMessage())->isInstanceOf(SmsTextMessage::class);
}
/**
@ -50,7 +50,7 @@ class TextRequest extends Request implements SmsRequestInterface
return Response::class;
}
public function getRawBody() : array
public function getRawBody(): array
{
return array_merge(
parent::getRawBody(),
@ -60,4 +60,4 @@ class TextRequest extends Request implements SmsRequestInterface
]
);
}
}
}

Voir le fichier

@ -13,7 +13,7 @@
* @link http://www.oxidmodule.com
*/
declare( strict_types = 1 );
declare(strict_types=1);
namespace D3\LinkmobilityClient;
@ -28,4 +28,4 @@ class Url implements UrlInterface
{
return $this->baseUri;
}
}
}

Voir le fichier

@ -18,4 +18,4 @@ namespace D3\LinkmobilityClient;
interface UrlInterface
{
public function getBaseUri(): string;
}
}

Voir le fichier

@ -46,7 +46,7 @@ class Recipient extends StringValueObject
/**
* @return string
*/
public function getCountryCode() :string
public function getCountryCode(): string
{
return $this->countryCode;
}

Voir le fichier

@ -26,14 +26,14 @@ class Sender extends StringValueObject
$phoneUtil = $this->getPhoneNumberUtil();
$phoneNumber = $phoneUtil->parse( $number, strtoupper($iso2CountryCode) );
$phoneNumber = $phoneUtil->parse($number, strtoupper($iso2CountryCode));
$number = ltrim($phoneUtil->format($phoneNumber, PhoneNumberFormat::E164), '+');
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
throw new RecipientException( ExceptionMessages::INVALID_SENDER );
throw new RecipientException(ExceptionMessages::INVALID_SENDER);
}
parent::__construct( $number);
parent::__construct($number);
}
/**

Voir le fichier

@ -13,7 +13,7 @@ class SmsBinaryMessage extends SmsMessageAbstract
*/
public function __construct(string $message)
{
parent::__construct( $message);
parent::__construct($message);
$this->getSmsLength()->validate();
}

Voir le fichier

@ -19,7 +19,7 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
/**
* @return int
*/
public function chunkCount() : int
public function chunkCount(): int
{
return $this->getSmsLength()->getMessageCount();
}
@ -27,7 +27,7 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
/**
* @return int
*/
public function length() : int
public function length(): int
{
return $this->getSmsLength()->getSize();
}

Voir le fichier

@ -17,9 +17,9 @@ namespace D3\LinkmobilityClient\ValueObject;
interface SmsMessageInterface
{
public function chunkCount() : int;
public function chunkCount(): int;
public function length() : int;
public function length(): int;
public function getMessageContent();
}
}

Voir le fichier

@ -14,7 +14,7 @@ class SmsTextMessage extends SmsMessageAbstract
*/
public function __construct(string $message)
{
parent::__construct( $message);
parent::__construct($message);
$smsLength = $this->getSmsLength();
$smsLength->validate();

Voir le fichier

@ -10,7 +10,7 @@ abstract class StringValueObject extends ValueObject
{
public function __construct(string $number)
{
Assert::that( $number)->notEmpty();
Assert::that($number)->notEmpty();
$this->value = $number;
}