apply PSR-12 rules
This commit is contained in:
parent
fd8a3c93ad
commit
2acb1c9fb6
13
.php-cs-fixer.php
Normal file
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);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests;
|
namespace D3\LinkmobilityClient\Tests;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ class ClientTest extends ApiTestCase
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\RecipientsList;
|
namespace D3\LinkmobilityClient\Tests\RecipientsList;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class RecipientsListTest extends ApiTestCase
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -164,11 +164,11 @@ class RecipientsListTest extends ApiTestCase
|
|||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
if ($unparsable) {
|
if ($unparsable) {
|
||||||
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
|
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
|
||||||
} else {
|
} 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);
|
$phoneNumberUtilMock->method('getNumberType')->willReturn($invalidNumberType ? PhoneNumberType::FIXED_LINE : PhoneNumberType::MOBILE);
|
||||||
|
|
||||||
/** @var Recipient|MockObject $recipientMock */
|
/** @var Recipient|MockObject $recipientMock */
|
||||||
@ -435,32 +435,32 @@ class RecipientsListTest extends ApiTestCase
|
|||||||
protected function addRecipientFixture(): array
|
protected function addRecipientFixture(): array
|
||||||
{
|
{
|
||||||
/** @var Recipient|MockObject $recipientMock */
|
/** @var Recipient|MockObject $recipientMock */
|
||||||
$recipientMock = $this->getMockBuilder( Recipient::class )
|
$recipientMock = $this->getMockBuilder(Recipient::class)
|
||||||
->onlyMethods( [
|
->onlyMethods([
|
||||||
'get',
|
'get',
|
||||||
'getCountryCode'
|
'getCountryCode'
|
||||||
] )
|
])
|
||||||
->setConstructorArgs( [
|
->setConstructorArgs([
|
||||||
$this->phoneNumberFixture,
|
$this->phoneNumberFixture,
|
||||||
$this->phoneCountryFixture
|
$this->phoneCountryFixture
|
||||||
] )
|
])
|
||||||
->getMock();
|
->getMock();
|
||||||
$recipientMock->method( 'get' )->willReturn( $this->phoneNumberFixture );
|
$recipientMock->method('get')->willReturn($this->phoneNumberFixture);
|
||||||
$recipientMock->method( 'getCountryCode' )->willReturn( $this->phoneCountryFixture );
|
$recipientMock->method('getCountryCode')->willReturn($this->phoneCountryFixture);
|
||||||
|
|
||||||
/** @var Recipient|MockObject $recipientMock2 */
|
/** @var Recipient|MockObject $recipientMock2 */
|
||||||
$recipientMock2 = $this->getMockBuilder( Recipient::class )
|
$recipientMock2 = $this->getMockBuilder(Recipient::class)
|
||||||
->onlyMethods( [
|
->onlyMethods([
|
||||||
'get',
|
'get',
|
||||||
'getCountryCode'
|
'getCountryCode'
|
||||||
] )
|
])
|
||||||
->setConstructorArgs( [
|
->setConstructorArgs([
|
||||||
$this->phoneNumberFixture,
|
$this->phoneNumberFixture,
|
||||||
$this->phoneCountryFixture
|
$this->phoneCountryFixture
|
||||||
] )
|
])
|
||||||
->getMock();
|
->getMock();
|
||||||
$recipientMock2->method( 'get' )->willReturn( $this->phoneNumberFixture );
|
$recipientMock2->method('get')->willReturn($this->phoneNumberFixture);
|
||||||
$recipientMock2->method( 'getCountryCode' )->willReturn( $this->phoneCountryFixture );
|
$recipientMock2->method('getCountryCode')->willReturn($this->phoneCountryFixture);
|
||||||
|
|
||||||
$list = [
|
$list = [
|
||||||
'fixture' => $recipientMock,
|
'fixture' => $recipientMock,
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\Request;
|
namespace D3\LinkmobilityClient\Tests\Request;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\Response;
|
namespace D3\LinkmobilityClient\Tests\Response;
|
||||||
|
|
||||||
@ -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'
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\SMS;
|
namespace D3\LinkmobilityClient\Tests\SMS;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\SMS;
|
namespace D3\LinkmobilityClient\Tests\SMS;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\SMS;
|
namespace D3\LinkmobilityClient\Tests\SMS;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\SMS;
|
namespace D3\LinkmobilityClient\Tests\SMS;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests;
|
namespace D3\LinkmobilityClient\Tests;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ class UrlTest extends ApiTestCase
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class RecipientTest extends ApiTestCase
|
|||||||
* @return void
|
* @return void
|
||||||
* @throws NumberParseException
|
* @throws NumberParseException
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@ -116,9 +116,9 @@ class RecipientTest extends ApiTestCase
|
|||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
if ($number === 'abc') {
|
if ($number === 'abc') {
|
||||||
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
|
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
|
||||||
} else {
|
} else {
|
||||||
$phoneNumberUtilMock->method( 'parse' )->willReturn( new PhoneNumber() );
|
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber());
|
||||||
}
|
}
|
||||||
$phoneNumberUtilMock->method('format')->willReturn($number);
|
$phoneNumberUtilMock->method('format')->willReturn($number);
|
||||||
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
|
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||||
|
|
||||||
@ -40,11 +40,11 @@ class SenderTest extends ApiTestCase
|
|||||||
* @throws NumberParseException
|
* @throws NumberParseException
|
||||||
* @throws RecipientException
|
* @throws RecipientException
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
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()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
if ($number === 'abc') {
|
if ($number === 'abc') {
|
||||||
$phoneNumberUtilMock->method( 'parse' )->willThrowException(new NumberParseException(0, 'message'));
|
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message'));
|
||||||
} else {
|
} else {
|
||||||
$phoneNumberUtilMock->method( 'parse' )->willReturn( new PhoneNumber() );
|
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber());
|
||||||
}
|
}
|
||||||
$phoneNumberUtilMock->method('format')->willReturn($number);
|
$phoneNumberUtilMock->method('format')->willReturn($number);
|
||||||
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
|
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||||
|
|
||||||
@ -34,11 +34,11 @@ class SmsBinaryMessageTest extends ApiTestCase
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->message = new SmsBinaryMessage( $this->messageFixture);
|
$this->message = new SmsBinaryMessage($this->messageFixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,9 +100,9 @@ class SmsBinaryMessageTest extends ApiTestCase
|
|||||||
->onlyMethods(['validate'])
|
->onlyMethods(['validate'])
|
||||||
->getMock();
|
->getMock();
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$smsLengthMock->expects( $this->never() )->method( 'validate' )->willReturn( true );
|
$smsLengthMock->expects($this->never())->method('validate')->willReturn(true);
|
||||||
} else {
|
} 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 */
|
/** @var SmsBinaryMessage|MockObject $message */
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
namespace D3\LinkmobilityClient\Tests\ValueObject;
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
|
|||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp():void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->message = new SmsTextMessage( $this->messageFixture);
|
$this->message = new SmsTextMessage($this->messageFixture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,9 +89,9 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
|
|||||||
->onlyMethods(['validate'])
|
->onlyMethods(['validate'])
|
||||||
->getMock();
|
->getMock();
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
$smsLengthMock->expects( $this->never() )->method( 'validate' )->willReturn( true );
|
$smsLengthMock->expects($this->never())->method('validate')->willReturn(true);
|
||||||
} else {
|
} else {
|
||||||
$smsLengthMock->expects( $this->atLeastOnce() )->method( 'validate' )->willThrowException(new InvalidArgumentException());
|
$smsLengthMock->expects($this->atLeastOnce())->method('validate')->willThrowException(new InvalidArgumentException());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var SmsTextMessage|MockObject $message */
|
/** @var SmsTextMessage|MockObject $message */
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient;
|
namespace D3\LinkmobilityClient;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class Client
|
|||||||
{
|
{
|
||||||
$this->accessToken = $accessToken;
|
$this->accessToken = $accessToken;
|
||||||
$this->apiUrl = $apiUrl ?: new Url();
|
$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 GuzzleException
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function request(RequestInterface $request) : Response\ResponseInterface
|
public function request(RequestInterface $request): Response\ResponseInterface
|
||||||
{
|
{
|
||||||
$request->validate();
|
$request->validate();
|
||||||
|
|
||||||
@ -67,11 +67,13 @@ class Client
|
|||||||
* @throws ApiException
|
* @throws ApiException
|
||||||
* @throws GuzzleException
|
* @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;
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +102,7 @@ class Client
|
|||||||
*
|
*
|
||||||
* @return Client
|
* @return Client
|
||||||
*/
|
*/
|
||||||
public function setLogger(LoggerInterface $logger ) : Client
|
public function setLogger(LoggerInterface $logger): Client
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
|
||||||
@ -108,7 +112,7 @@ class Client
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasLogger() : bool
|
public function hasLogger(): bool
|
||||||
{
|
{
|
||||||
return $this->logger instanceof LoggerInterface;
|
return $this->logger instanceof LoggerInterface;
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -38,7 +38,7 @@ class RecipientsList implements RecipientsListInterface, Iterator
|
|||||||
*/
|
*/
|
||||||
private $recipients = [];
|
private $recipients = [];
|
||||||
|
|
||||||
public function __construct( Client $client )
|
public function __construct(Client $client)
|
||||||
{
|
{
|
||||||
$this->setClient($client);
|
$this->setClient($client);
|
||||||
}
|
}
|
||||||
@ -56,28 +56,27 @@ class RecipientsList implements RecipientsListInterface, Iterator
|
|||||||
*
|
*
|
||||||
* @return RecipientsListInterface
|
* @return RecipientsListInterface
|
||||||
*/
|
*/
|
||||||
public function add(Recipient $recipient) : RecipientsListInterface
|
public function add(Recipient $recipient): RecipientsListInterface
|
||||||
{
|
{
|
||||||
$phoneUtil = $this->getPhoneNumberUtil();
|
$phoneUtil = $this->getPhoneNumberUtil();
|
||||||
try {
|
try {
|
||||||
$phoneNumber = $phoneUtil->parse( $recipient->get(), $recipient->getCountryCode() );
|
$phoneNumber = $phoneUtil->parse($recipient->get(), $recipient->getCountryCode());
|
||||||
|
|
||||||
if ( false === $phoneUtil->isValidNumber( $phoneNumber ) ) {
|
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
|
||||||
throw new RecipientException( ExceptionMessages::INVALID_RECIPIENT_PHONE );
|
throw new RecipientException(ExceptionMessages::INVALID_RECIPIENT_PHONE);
|
||||||
} elseif (
|
} elseif (
|
||||||
false === in_array(
|
false === in_array(
|
||||||
$phoneUtil->getNumberType( $phoneNumber ),
|
$phoneUtil->getNumberType($phoneNumber),
|
||||||
[
|
[
|
||||||
PhoneNumberType::MOBILE,
|
PhoneNumberType::MOBILE,
|
||||||
PhoneNumberType::FIXED_LINE_OR_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) {
|
} catch (NumberParseException $e) {
|
||||||
if ($this->getClient()->hasLogger()) {
|
if ($this->getClient()->hasLogger()) {
|
||||||
$this->getClient()->getLogger()->info($e->getMessage());
|
$this->getClient()->getLogger()->info($e->getMessage());
|
||||||
@ -94,14 +93,14 @@ class RecipientsList implements RecipientsListInterface, Iterator
|
|||||||
/**
|
/**
|
||||||
* @return RecipientsListInterface
|
* @return RecipientsListInterface
|
||||||
*/
|
*/
|
||||||
public function clearRecipents() : RecipientsListInterface
|
public function clearRecipents(): RecipientsListInterface
|
||||||
{
|
{
|
||||||
$this->recipients = [];
|
$this->recipients = [];
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRecipients() : array
|
public function getRecipients(): array
|
||||||
{
|
{
|
||||||
return array_values(
|
return array_values(
|
||||||
array_map(
|
array_map(
|
||||||
@ -116,7 +115,7 @@ class RecipientsList implements RecipientsListInterface, Iterator
|
|||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getRecipientsList() : array
|
public function getRecipientsList(): array
|
||||||
{
|
{
|
||||||
return $this->recipients;
|
return $this->recipients;
|
||||||
}
|
}
|
||||||
@ -165,7 +164,7 @@ class RecipientsList implements RecipientsListInterface, Iterator
|
|||||||
*
|
*
|
||||||
* @return RecipientsList
|
* @return RecipientsList
|
||||||
*/
|
*/
|
||||||
public function setClient( Client $client ): RecipientsList
|
public function setClient(Client $client): RecipientsList
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
|
||||||
|
@ -24,9 +24,9 @@ interface RecipientsListInterface
|
|||||||
{
|
{
|
||||||
public function __construct(Client $client);
|
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;
|
||||||
}
|
}
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\Request;
|
namespace D3\LinkmobilityClient\Request;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ abstract class Request implements RequestInterface
|
|||||||
public function __construct(SmsMessageInterface $message, Client $client)
|
public function __construct(SmsMessageInterface $message, Client $client)
|
||||||
{
|
{
|
||||||
$this->recipientsList = new RecipientsList($client);
|
$this->recipientsList = new RecipientsList($client);
|
||||||
$this->setMessage( $message );
|
$this->setMessage($message);
|
||||||
$this->setClient($client);
|
$this->setClient($client);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -129,30 +129,30 @@ abstract class Request implements RequestInterface
|
|||||||
*/
|
*/
|
||||||
public function validate()
|
public function validate()
|
||||||
{
|
{
|
||||||
Assert::that( $this->getMethod() )->choice( self::getMethods() );
|
Assert::that($this->getMethod())->choice(self::getMethods());
|
||||||
Assert::that( $this->getUri() )->string()->startsWith( '/' );
|
Assert::that($this->getUri())->string()->startsWith('/');
|
||||||
|
|
||||||
Assert::that($this->getBody())->isArray();
|
Assert::that($this->getBody())->isArray();
|
||||||
Assert::that($this->getResponseClass())->implementsInterface(ResponseInterface::class);
|
Assert::that($this->getResponseClass())->implementsInterface(ResponseInterface::class);
|
||||||
Assert::that($this->getOptions())->isArray();
|
Assert::that($this->getOptions())->isArray();
|
||||||
|
|
||||||
Assert::that( $this->getRecipientsList() )->isInstanceOf(RecipientsList::class)->notEmpty();
|
Assert::that($this->getRecipientsList())->isInstanceOf(RecipientsList::class)->notEmpty();
|
||||||
Assert::that( $this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient');
|
Assert::that($this->getRecipientsList()->getRecipients())->notEmpty('request must contain a valid recipient');
|
||||||
Assert::thatAll( $this->getRecipientsList() )->isInstanceOf( Recipient::class )->notEmpty();
|
Assert::thatAll($this->getRecipientsList())->isInstanceOf(Recipient::class)->notEmpty();
|
||||||
|
|
||||||
// optional properties
|
// optional properties
|
||||||
Assert::thatNullOr( $this->getClientMessageId() )->string();
|
Assert::thatNullOr($this->getClientMessageId())->string();
|
||||||
Assert::thatNullOr( $this->getContentCategory() )->choice(self::getContentCategories());
|
Assert::thatNullOr($this->getContentCategory())->choice(self::getContentCategories());
|
||||||
Assert::thatNullOr( $this->getNotificationCallbackUrl() )->url();
|
Assert::thatNullOr($this->getNotificationCallbackUrl())->url();
|
||||||
Assert::thatNullOr( $this->getPriority() )->integer();
|
Assert::thatNullOr($this->getPriority())->integer();
|
||||||
Assert::thatNullOr( $this->doSendAsFlashSms() )->boolean();
|
Assert::thatNullOr($this->doSendAsFlashSms())->boolean();
|
||||||
Assert::thatNullOr( $this->getSenderAddress() )->isInstanceOf(Sender::class);
|
Assert::thatNullOr($this->getSenderAddress())->isInstanceOf(Sender::class);
|
||||||
Assert::thatNullOr( $this->getSenderAddressType() )->choice(self::getSenderAddressTypes());
|
Assert::thatNullOr($this->getSenderAddressType())->choice(self::getSenderAddressTypes());
|
||||||
Assert::thatNullOr( $this->getTestMode() )->boolean();
|
Assert::thatNullOr($this->getTestMode())->boolean();
|
||||||
Assert::thatNullOr( $this->getValidityPeriode() )->integer();
|
Assert::thatNullOr($this->getValidityPeriode())->integer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawBody() : array
|
public function getRawBody(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'clientMessageId' => $this->getClientMessageId(),
|
'clientMessageId' => $this->getClientMessageId(),
|
||||||
@ -174,9 +174,9 @@ abstract class Request implements RequestInterface
|
|||||||
*/
|
*/
|
||||||
public function getBody(): array
|
public function getBody(): array
|
||||||
{
|
{
|
||||||
$body = array_filter( $this->getRawBody(), function( $elm ) {
|
$body = array_filter($this->getRawBody(), function ($elm) {
|
||||||
return ! is_null( $elm );
|
return ! is_null($elm);
|
||||||
} );
|
});
|
||||||
|
|
||||||
switch ($this->getContentType()) {
|
switch ($this->getContentType()) {
|
||||||
case RequestInterface::CONTENTTYPE_JSON:
|
case RequestInterface::CONTENTTYPE_JSON:
|
||||||
@ -259,7 +259,7 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContentType() : string
|
public function getContentType(): string
|
||||||
{
|
{
|
||||||
return $this->contentType;
|
return $this->contentType;
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContentCategory() : string
|
public function getContentCategory(): string
|
||||||
{
|
{
|
||||||
return $this->contentCategory;
|
return $this->contentCategory;
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTestMode() : bool
|
public function getTestMode(): bool
|
||||||
{
|
{
|
||||||
return $this->test;
|
return $this->test;
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxSmsPerMessage() : int
|
public function getMaxSmsPerMessage(): int
|
||||||
{
|
{
|
||||||
return $this->maxSmsPerMessage;
|
return $this->maxSmsPerMessage;
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ abstract class Request implements RequestInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMessageType() : string
|
public function getMessageType(): string
|
||||||
{
|
{
|
||||||
return $this->messageType;
|
return $this->messageType;
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ abstract class Request implements RequestInterface
|
|||||||
/**
|
/**
|
||||||
* @return RecipientsListInterface
|
* @return RecipientsListInterface
|
||||||
*/
|
*/
|
||||||
public function getRecipientsList() : RecipientsListInterface
|
public function getRecipientsList(): RecipientsListInterface
|
||||||
{
|
{
|
||||||
return $this->recipientsList;
|
return $this->recipientsList;
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ abstract class Request implements RequestInterface
|
|||||||
/**
|
/**
|
||||||
* @return bool|null
|
* @return bool|null
|
||||||
*/
|
*/
|
||||||
public function doSendAsFlashSms() : bool
|
public function doSendAsFlashSms(): bool
|
||||||
{
|
{
|
||||||
return $this->sendAsFlashSms;
|
return $this->sendAsFlashSms;
|
||||||
}
|
}
|
||||||
@ -483,7 +483,7 @@ abstract class Request implements RequestInterface
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setValidityPeriode( int $validityPeriode): Request
|
public function setValidityPeriode(int $validityPeriode): Request
|
||||||
{
|
{
|
||||||
$this->validityPeriode = $validityPeriode;
|
$this->validityPeriode = $validityPeriode;
|
||||||
|
|
||||||
@ -520,7 +520,7 @@ abstract class Request implements RequestInterface
|
|||||||
/**
|
/**
|
||||||
* @param Client $client
|
* @param Client $client
|
||||||
*/
|
*/
|
||||||
public function setClient( Client $client ): Request
|
public function setClient(Client $client): Request
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
@ -53,28 +53,28 @@ interface RequestInterface
|
|||||||
*
|
*
|
||||||
* @return string
|
* @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
|
* Must return the URI for the request with a leading slash, i.e. /messages.json
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUri() : string;
|
public function getUri(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must return the body which is being sent as json
|
* Must return the body which is being sent as json
|
||||||
*
|
*
|
||||||
* @return array
|
* @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
|
* Must return the class to where the response is handed over. It must implement the ResponseInterface
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getResponseClass() : string;
|
public function getResponseClass(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PsrResponseInterface $rawResponse
|
* @param PsrResponseInterface $rawResponse
|
||||||
@ -88,7 +88,7 @@ interface RequestInterface
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getOptions() : array;
|
public function getOptions(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must validate the input of the request
|
* Must validate the input of the request
|
||||||
|
@ -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
|
||||||
@ -32,7 +33,7 @@ abstract class Response implements ResponseInterface
|
|||||||
$this->content = json_decode($this->rawResponse->getBody()->getContents(), true);
|
$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;
|
return $this->rawResponse;
|
||||||
}
|
}
|
||||||
@ -45,7 +46,7 @@ abstract class Response implements ResponseInterface
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getInternalStatus() : int
|
public function getInternalStatus(): int
|
||||||
{
|
{
|
||||||
return $this->getContent()[self::STATUSCODE];
|
return $this->getContent()[self::STATUSCODE];
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ abstract class Response implements ResponseInterface
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getStatusMessage() : string
|
public function getStatusMessage(): string
|
||||||
{
|
{
|
||||||
return $this->getContent()[self::STATUSMESSAGE];
|
return $this->getContent()[self::STATUSMESSAGE];
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ abstract class Response implements ResponseInterface
|
|||||||
/**
|
/**
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function getSmsCount() : int
|
public function getSmsCount(): int
|
||||||
{
|
{
|
||||||
return $this->getContent()[self::SMSCOUNT];
|
return $this->getContent()[self::SMSCOUNT];
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,17 @@ interface ResponseInterface
|
|||||||
{
|
{
|
||||||
public function __construct(\Psr\Http\Message\ResponseInterface $rawResponse);
|
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 getClientMessageId();
|
||||||
|
|
||||||
public function getTransferId();
|
public function getTransferId();
|
||||||
|
|
||||||
public function getSmsCount() : int;
|
public function getSmsCount(): int;
|
||||||
|
|
||||||
public function isSuccessful(): bool;
|
public function isSuccessful(): bool;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\SMS;
|
namespace D3\LinkmobilityClient\SMS;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
|
|||||||
return '/rest/smsmessaging/binary';
|
return '/rest/smsmessaging/binary';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawBody() : array
|
public function getRawBody(): array
|
||||||
{
|
{
|
||||||
return array_merge(
|
return array_merge(
|
||||||
parent::getRawBody(),
|
parent::getRawBody(),
|
||||||
@ -49,7 +49,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
|
|||||||
{
|
{
|
||||||
parent::validate();
|
parent::validate();
|
||||||
|
|
||||||
Assert::thatNullOr( $this->getMessage() )->isInstanceOf(SmsBinaryMessage::class);
|
Assert::thatNullOr($this->getMessage())->isInstanceOf(SmsBinaryMessage::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\SMS;
|
namespace D3\LinkmobilityClient\SMS;
|
||||||
|
|
||||||
@ -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;
|
||||||
@ -46,7 +46,7 @@ class RequestFactory
|
|||||||
/**
|
/**
|
||||||
* @return SmsRequestInterface
|
* @return SmsRequestInterface
|
||||||
*/
|
*/
|
||||||
public function getSmsRequest() : SmsRequestInterface
|
public function getSmsRequest(): SmsRequestInterface
|
||||||
{
|
{
|
||||||
if ($this->getSmsLength()->getEncoding() === self::GSM_7BIT) {
|
if ($this->getSmsLength()->getEncoding() === self::GSM_7BIT) {
|
||||||
$message = new SmsTextMessage($this->message);
|
$message = new SmsTextMessage($this->message);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\SMS;
|
namespace D3\LinkmobilityClient\SMS;
|
||||||
|
|
||||||
@ -21,5 +21,5 @@ interface RequestFactoryInterface
|
|||||||
{
|
{
|
||||||
public function __construct($message);
|
public function __construct($message);
|
||||||
|
|
||||||
public function getRequest() : SmsRequestInterface;
|
public function getRequest(): SmsRequestInterface;
|
||||||
}
|
}
|
@ -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
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient\SMS;
|
namespace D3\LinkmobilityClient\SMS;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ class TextRequest extends Request implements SmsRequestInterface
|
|||||||
{
|
{
|
||||||
parent::validate();
|
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;
|
return Response::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRawBody() : array
|
public function getRawBody(): array
|
||||||
{
|
{
|
||||||
return array_merge(
|
return array_merge(
|
||||||
parent::getRawBody(),
|
parent::getRawBody(),
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare( strict_types = 1 );
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace D3\LinkmobilityClient;
|
namespace D3\LinkmobilityClient;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Recipient extends StringValueObject
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getCountryCode() :string
|
public function getCountryCode(): string
|
||||||
{
|
{
|
||||||
return $this->countryCode;
|
return $this->countryCode;
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ class Sender extends StringValueObject
|
|||||||
|
|
||||||
$phoneUtil = $this->getPhoneNumberUtil();
|
$phoneUtil = $this->getPhoneNumberUtil();
|
||||||
|
|
||||||
$phoneNumber = $phoneUtil->parse( $number, strtoupper($iso2CountryCode) );
|
$phoneNumber = $phoneUtil->parse($number, strtoupper($iso2CountryCode));
|
||||||
$number = ltrim($phoneUtil->format($phoneNumber, PhoneNumberFormat::E164), '+');
|
$number = ltrim($phoneUtil->format($phoneNumber, PhoneNumberFormat::E164), '+');
|
||||||
|
|
||||||
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
|
if (false === $phoneUtil->isValidNumber($phoneNumber)) {
|
||||||
throw new RecipientException( ExceptionMessages::INVALID_SENDER );
|
throw new RecipientException(ExceptionMessages::INVALID_SENDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct( $number);
|
parent::__construct($number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@ class SmsBinaryMessage extends SmsMessageAbstract
|
|||||||
*/
|
*/
|
||||||
public function __construct(string $message)
|
public function __construct(string $message)
|
||||||
{
|
{
|
||||||
parent::__construct( $message);
|
parent::__construct($message);
|
||||||
|
|
||||||
$this->getSmsLength()->validate();
|
$this->getSmsLength()->validate();
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function chunkCount() : int
|
public function chunkCount(): int
|
||||||
{
|
{
|
||||||
return $this->getSmsLength()->getMessageCount();
|
return $this->getSmsLength()->getMessageCount();
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
|
|||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function length() : int
|
public function length(): int
|
||||||
{
|
{
|
||||||
return $this->getSmsLength()->getSize();
|
return $this->getSmsLength()->getSize();
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ namespace D3\LinkmobilityClient\ValueObject;
|
|||||||
|
|
||||||
interface SmsMessageInterface
|
interface SmsMessageInterface
|
||||||
{
|
{
|
||||||
public function chunkCount() : int;
|
public function chunkCount(): int;
|
||||||
|
|
||||||
public function length() : int;
|
public function length(): int;
|
||||||
|
|
||||||
public function getMessageContent();
|
public function getMessageContent();
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ class SmsTextMessage extends SmsMessageAbstract
|
|||||||
*/
|
*/
|
||||||
public function __construct(string $message)
|
public function __construct(string $message)
|
||||||
{
|
{
|
||||||
parent::__construct( $message);
|
parent::__construct($message);
|
||||||
|
|
||||||
$smsLength = $this->getSmsLength();
|
$smsLength = $this->getSmsLength();
|
||||||
$smsLength->validate();
|
$smsLength->validate();
|
||||||
|
@ -10,7 +10,7 @@ abstract class StringValueObject extends ValueObject
|
|||||||
{
|
{
|
||||||
public function __construct(string $number)
|
public function __construct(string $number)
|
||||||
{
|
{
|
||||||
Assert::that( $number)->notEmpty();
|
Assert::that($number)->notEmpty();
|
||||||
|
|
||||||
$this->value = $number;
|
$this->value = $number;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user