adjust to current dependency packages and PHP >= 7.3

This commit is contained in:
Daniel Seifert 2022-07-19 23:20:33 +02:00 committed by Daniel Seifert
parent b22da1bd4a
commit 7e43fa1537
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
27 changed files with 122 additions and 114 deletions

View File

@ -6,7 +6,7 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config(); $config = new PhpCsFixer\Config();
return $config->setRules([ return $config->setRules([
'@PHP70Migration' => true, '@PHP73Migration' => true,
'@PSR12' => true '@PSR12' => true
]) ])
->setFinder($finder) ->setFinder($finder)

View File

@ -2,6 +2,12 @@
--- ---
## 2.0.0.0 (2022-07-19)
- adjust to PHP >= 7.3 and current dependency packages
---
## 1.3.0.0 (2022-07-18) ## 1.3.0.0 (2022-07-18)
- tests use generated example phone numbers - tests use generated example phone numbers

View File

@ -96,7 +96,7 @@ class ClientTest extends ApiTestCase
return [ return [
'api key only' => ['apiKey', null, null], 'api key only' => ['apiKey', null, null],
'all without client' => ['apiKey', new Url(), null], 'all without client' => ['apiKey', new Url(), null],
'all arguments' => ['apiKey', new Url(), new GuzzleClient()] 'all arguments' => ['apiKey', new Url(), new GuzzleClient()],
]; ];
} }
@ -167,7 +167,7 @@ class ClientTest extends ApiTestCase
{ {
return [ return [
'request is valid' => [true], 'request is valid' => [true],
'request is not valid' => [false] 'request is not valid' => [false],
]; ];
} }
@ -203,7 +203,7 @@ class ClientTest extends ApiTestCase
'withHeader', 'withHeader',
'withAddedHeader', 'withAddedHeader',
'withoutHeader', 'withoutHeader',
'withBody' 'withBody',
]) ])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
@ -232,7 +232,7 @@ class ClientTest extends ApiTestCase
$clientMock = $this->getMockBuilder(Client::class) $clientMock = $this->getMockBuilder(Client::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->onlyMethods([ ->onlyMethods([
'getLoggerHandler' 'getLoggerHandler',
]) ])
->getMock(); ->getMock();
$clientMock->expects($this->atLeastOnce()) $clientMock->expects($this->atLeastOnce())

View File

@ -167,7 +167,7 @@ class RecipientsListTest extends ApiTestCase
$this->assertSame( $this->assertSame(
[ [
$this->phoneNumberFixture, $this->phoneNumberFixture,
$this->phoneNumberFixture $this->phoneNumberFixture,
], ],
$this->callMethod( $this->callMethod(
$this->recipientsList, $this->recipientsList,
@ -280,7 +280,7 @@ class RecipientsListTest extends ApiTestCase
$this->recipientsList, $this->recipientsList,
'recipients', 'recipients',
[ [
'fixture' => new stdClass() 'fixture' => new stdClass(),
] ]
); );
@ -333,11 +333,11 @@ class RecipientsListTest extends ApiTestCase
$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);
@ -347,11 +347,11 @@ class RecipientsListTest extends ApiTestCase
$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);
@ -359,7 +359,7 @@ class RecipientsListTest extends ApiTestCase
$list = [ $list = [
'fixture' => $recipientMock, 'fixture' => $recipientMock,
'fixture2' => $recipientMock2 'fixture2' => $recipientMock2,
]; ];
$this->setValue( $this->setValue(

View File

@ -17,6 +17,7 @@ namespace D3\LinkmobilityClient\Tests\Request;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Client; use D3\LinkmobilityClient\Client;
use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface; use D3\LinkmobilityClient\RecipientsList\RecipientsListInterface;
use D3\LinkmobilityClient\Request\Request; use D3\LinkmobilityClient\Request\Request;
use D3\LinkmobilityClient\Request\RequestInterface; use D3\LinkmobilityClient\Request\RequestInterface;
@ -24,6 +25,7 @@ use D3\LinkmobilityClient\SMS\Response;
use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Recipient; use D3\LinkmobilityClient\ValueObject\Recipient;
use D3\LinkmobilityClient\ValueObject\Sender; use D3\LinkmobilityClient\ValueObject\Sender;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType; use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil; use libphonenumber\PhoneNumberUtil;
@ -115,10 +117,13 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate * @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate * @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
* @covers \D3\LinkmobilityClient\Request\Request::validate * @covers \D3\LinkmobilityClient\Request\Request::validate
* @return void
* @throws ReflectionException
* @throws RecipientException
* @throws NumberParseException
*/ */
public function validatePassedTest() public function validatePassedTest()
{ {
@ -149,9 +154,12 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate * @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate * @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
* @return void
* @throws NumberParseException
* @throws RecipientException
* @throws ReflectionException
*/ */
public function validateFailedTest() public function validateFailedTest()
{ {
@ -253,17 +261,17 @@ abstract class AbstractRequest extends ApiTestCase
['json' => [ ['json' => [
'contentCategory' => 'informational', 'contentCategory' => 'informational',
'messageContent' => 'messageContent', 'messageContent' => 'messageContent',
'priority' => 0 'priority' => 0,
]] ]],
], ],
'other' => [ 'other' => [
'other', 'other',
[ [
'contentCategory' => 'informational', 'contentCategory' => 'informational',
'messageContent' => 'messageContent', 'messageContent' => 'messageContent',
'priority' => 0 'priority' => 0,
] ],
] ],
]; ];
} }
@ -284,20 +292,20 @@ abstract class AbstractRequest extends ApiTestCase
['json' => [ ['json' => [
'contentCategory' => 'informational', 'contentCategory' => 'informational',
'messageContent' => 'messageContent', 'messageContent' => 'messageContent',
'priority' => 0 'priority' => 0,
]] ]]
); );
$this->assertSame( $this->assertSame(
['headers' => [ ['headers' => [
'Accept' => 'application/json', 'Accept' => 'application/json',
'Content-Type' => 'application/json' 'Content-Type' => 'application/json',
], ],
'json' => [ 'json' => [
'contentCategory' => 'informational', 'contentCategory' => 'informational',
'messageContent' => 'messageContent', 'messageContent' => 'messageContent',
'priority' => 0 'priority' => 0,
]], ], ],
$this->callMethod( $this->callMethod(
$requestMock, $requestMock,
'getOptions' 'getOptions'
@ -671,7 +679,7 @@ abstract class AbstractRequest extends ApiTestCase
/** @var StreamInterface|MockObject $streamMock */ /** @var StreamInterface|MockObject $streamMock */
$streamMock = $this->getMockBuilder(StreamInterface::class) $streamMock = $this->getMockBuilder(StreamInterface::class)
->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable', ->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable',
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata']) 'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata', ])
->getMock(); ->getMock();
$streamMock->method('getContents')->willReturn('{}'); $streamMock->method('getContents')->willReturn('{}');
@ -680,12 +688,12 @@ abstract class AbstractRequest extends ApiTestCase
->onlyMethods([ ->onlyMethods([
'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion', 'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion',
'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine', 'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine',
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody']) 'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody', ])
->getMock(); ->getMock();
$rawResponseMock->method('getBody')->willReturn($streamMock); $rawResponseMock->method('getBody')->willReturn($streamMock);
return [ return [
'SMS Response' => [$rawResponseMock] 'SMS Response' => [$rawResponseMock],
]; ];
} }

View File

@ -38,7 +38,7 @@ abstract class AbstractResponse extends ApiTestCase
/** @var StreamInterface|MockObject $streamMock */ /** @var StreamInterface|MockObject $streamMock */
$streamMock = $this->getMockBuilder(StreamInterface::class) $streamMock = $this->getMockBuilder(StreamInterface::class)
->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable', ->onlyMethods(['getContents', '__toString', 'close', 'detach', 'getSize', 'tell', 'eof', 'isSeekable',
'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata']) 'seek', 'rewind', 'isWritable', 'write', 'isReadable', 'read', 'getMetadata', ])
->getMock(); ->getMock();
$streamMock->expects($this->atLeastOnce())->method('getContents')->willReturn( $streamMock->expects($this->atLeastOnce())->method('getContents')->willReturn(
'{ '{
@ -53,7 +53,7 @@ abstract class AbstractResponse extends ApiTestCase
->onlyMethods([ ->onlyMethods([
'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion', 'getBody', 'getStatusCode', 'withStatus', 'getReasonphrase', 'getProtocolVersion',
'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine', 'withProtocolVersion', 'getHeaders', 'hasHeader', 'getHeader', 'getHeaderLine',
'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody']) 'withHeader', 'withAddedHeader', 'withoutHeader', 'withBody', ])
->getMock(); ->getMock();
$rawResponseMock->method('getBody')->willReturn($streamMock); $rawResponseMock->method('getBody')->willReturn($streamMock);
@ -226,7 +226,7 @@ abstract class AbstractResponse extends ApiTestCase
{ {
return [ return [
'successful' => [true, ''], 'successful' => [true, ''],
'not successful'=> [false, 'fixtureMessage'] 'not successful'=> [false, 'fixtureMessage'],
]; ];
} }
} }

View File

@ -100,8 +100,8 @@ class RequestFactoryTest extends ApiTestCase
public function getTextSmsRequestDataProvider(): array public function getTextSmsRequestDataProvider(): array
{ {
return [ return [
'binary' => [RequestFactory::GSM_UCS2, BinaryRequest::class], 'binary' => [SmsLength::ENCODING_UCS2, BinaryRequest::class],
'ascii' => [RequestFactory::GSM_7BIT, TextRequest::class] 'ascii' => [SmsLength::ENCODING_7BIT, TextRequest::class],
]; ];
} }

View File

@ -162,7 +162,7 @@ class RecipientTest extends ApiTestCase
'invalid country code' => [$phoneNumberFixture, 'DEX', true, PhoneNumberType::MOBILE, InvalidArgumentException::class], 'invalid country code' => [$phoneNumberFixture, 'DEX', true, PhoneNumberType::MOBILE, InvalidArgumentException::class],
'unparsable' => ['abc', 'DE', true, PhoneNumberType::MOBILE, NumberParseException::class], 'unparsable' => ['abc', 'DE', true, PhoneNumberType::MOBILE, NumberParseException::class],
'invalid number' => ['abcd', 'DE', false, PhoneNumberType::MOBILE, RecipientException::class], 'invalid number' => ['abcd', 'DE', false, PhoneNumberType::MOBILE, RecipientException::class],
'not mobile number' => ['abcd', 'DE', true, PhoneNumberType::FIXED_LINE, RecipientException::class] 'not mobile number' => ['abcd', 'DE', true, PhoneNumberType::FIXED_LINE, RecipientException::class],
]; ];
} }

View File

@ -16,7 +16,6 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject; namespace D3\LinkmobilityClient\Tests\ValueObject;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
use D3\LinkmobilityClient\Exceptions\RecipientException; use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Sender; use D3\LinkmobilityClient\ValueObject\Sender;
@ -112,7 +111,7 @@ class SenderTest extends ApiTestCase
return [ return [
'null number' => [null, $this->phoneCountryFixture, false], 'null number' => [null, $this->phoneCountryFixture, false],
'null country' => [$this->phoneNumberFixture, null, false], 'null country' => [$this->phoneNumberFixture, null, false],
'all values' => [$this->phoneNumberFixture, $this->phoneCountryFixture, true] 'all values' => [$this->phoneNumberFixture, $this->phoneCountryFixture, true],
]; ];
} }
@ -122,11 +121,9 @@ class SenderTest extends ApiTestCase
* @param $country * @param $country
* @param $validNumber * @param $validNumber
* @param $expectedException * @param $expectedException
* * @throws ReflectionException
* @throws NumberParseException
* @throws RecipientException
* @dataProvider constructInvalidDataProvider * @dataProvider constructInvalidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct * @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct
*/ */
public function testConstructInvalid($number, $country, $validNumber, $expectedException) public function testConstructInvalid($number, $country, $validNumber, $expectedException)
{ {
@ -174,7 +171,7 @@ class SenderTest extends ApiTestCase
'empty number' => ['', 'DE', true, InvalidArgumentException::class], 'empty number' => ['', 'DE', true, InvalidArgumentException::class],
'invalid country code' => [$phoneNumberFixture, 'DEX', true, InvalidArgumentException::class], 'invalid country code' => [$phoneNumberFixture, 'DEX', true, InvalidArgumentException::class],
'unparsable' => ['abc', 'DE', true, NumberParseException::class], 'unparsable' => ['abc', 'DE', true, NumberParseException::class],
'invalid number' => ['abcd', 'DE', false, RecipientException::class] 'invalid number' => ['abcd', 'DE', false, RecipientException::class],
]; ];
} }

View File

@ -131,7 +131,7 @@ class SmsBinaryMessageTest extends ApiTestCase
{ {
return [ return [
'empty message' => ['', true, InvalidArgumentException::class], 'empty message' => ['', true, InvalidArgumentException::class],
'invalid sms message' => ['abc', false, \Phlib\SmsLength\Exception\InvalidArgumentException::class] 'invalid sms message' => ['abc', false, \Phlib\SmsLength\Exception\InvalidArgumentException::class],
]; ];
} }

View File

@ -16,13 +16,8 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject; namespace D3\LinkmobilityClient\Tests\ValueObject;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Sender;
use D3\LinkmobilityClient\ValueObject\ValueObject; use D3\LinkmobilityClient\ValueObject\ValueObject;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType; use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil; use libphonenumber\PhoneNumberUtil;

View File

@ -21,18 +21,18 @@
"GPL-3.0-or-later" "GPL-3.0-or-later"
], ],
"require": { "require": {
"php": "^7.0 || ^8.0", "php": "^7.3 || ^8.0",
"beberlei/assert": "^2.9.9", "beberlei/assert": "^3.3",
"guzzlehttp/guzzle": "~6.2 || ^7.4", "guzzlehttp/guzzle": "^7.4",
"psr/http-message": "~1.0", "psr/http-message": "~1.0",
"phlib/sms-length": "^1.1.0 || ^2.0.0", "phlib/sms-length": "^2.0",
"giggsey/libphonenumber-for-php": "^8.12.50", "giggsey/libphonenumber-for-php": "^8.12.50",
"ext-json": "*" "ext-json": "*"
}, },
"require-dev": { "require-dev": {
"php": "^7.2", "php": "^7.4",
"phpunit/phpunit" : "^8.0", "phpunit/phpunit" : "^9.5",
"friendsofphp/php-cs-fixer": "^2.0" "friendsofphp/php-cs-fixer": "^3.9"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

View File

@ -1,22 +1,20 @@
<?xml version="1.0"?>
<phpunit <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true"> convertWarningsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<testsuite name="linkmobility"> <coverage>
<directory>./Tests</directory> <include>
</testsuite> <directory suffix=".php">src</directory>
</include>
<filter> <report>
<whitelist> <clover outputFile="build/logs/clover.xml"/>
<directory suffix=".php">src</directory> </report>
</whitelist> </coverage>
</filter> <testsuite name="linkmobility">
<directory>./Tests</directory>
<logging> </testsuite>
<log type="coverage-clover" target="build/logs/clover.xml"/> <logging/>
</logging>
</phpunit> </phpunit>

View File

@ -23,7 +23,7 @@ class LoggerHandler
private static $instance = null; private static $instance = null;
private $logger; private $logger;
public static function getInstance() public static function getInstance(): ?LoggerHandler
{ {
if (self::$instance === null) { if (self::$instance === null) {
self::$instance = new self(); self::$instance = new self();

View File

@ -169,7 +169,7 @@ abstract class Request implements RequestInterface
'senderAddress' => $this->getSenderAddress() ? $this->getSenderAddress()->getFormatted() : null, 'senderAddress' => $this->getSenderAddress() ? $this->getSenderAddress()->getFormatted() : null,
'senderAddressType' => $this->getSenderAddressType(), 'senderAddressType' => $this->getSenderAddressType(),
'test' => $this->getTestMode(), 'test' => $this->getTestMode(),
'validityPeriode' => $this->getValidityPeriode() 'validityPeriode' => $this->getValidityPeriode(),
]; ];
} }
@ -200,7 +200,7 @@ abstract class Request implements RequestInterface
'headers' => [ 'headers' => [
'Accept' => $this->contentType, 'Accept' => $this->contentType,
'Content-Type' => $this->contentType, 'Content-Type' => $this->contentType,
] ],
], ],
$this->getBody() $this->getBody()
); );
@ -280,7 +280,7 @@ abstract class Request implements RequestInterface
return $this; return $this;
} }
public function getClientMessageId() public function getClientMessageId(): ?string
{ {
return $this->clientMessageId; return $this->clientMessageId;
} }
@ -306,7 +306,7 @@ abstract class Request implements RequestInterface
{ {
return [ return [
RequestInterface::CONTENTCATEGORY_ADVERTISEMENT => RequestInterface::CONTENTCATEGORY_ADVERTISEMENT, RequestInterface::CONTENTCATEGORY_ADVERTISEMENT => RequestInterface::CONTENTCATEGORY_ADVERTISEMENT,
RequestInterface::CONTENTCATEGORY_INFORMATIONAL => RequestInterface::CONTENTCATEGORY_INFORMATIONAL RequestInterface::CONTENTCATEGORY_INFORMATIONAL => RequestInterface::CONTENTCATEGORY_INFORMATIONAL,
]; ];
} }
@ -376,7 +376,7 @@ abstract class Request implements RequestInterface
/** /**
* @return string|null * @return string|null
*/ */
public function getNotificationCallbackUrl() public function getNotificationCallbackUrl(): ?string
{ {
return $this->notificationCallbackUrl; return $this->notificationCallbackUrl;
} }
@ -396,7 +396,7 @@ abstract class Request implements RequestInterface
/** /**
* @return int|null * @return int|null
*/ */
public function getPriority() public function getPriority(): ?int
{ {
return $this->priority; return $this->priority;
} }
@ -444,7 +444,7 @@ abstract class Request implements RequestInterface
/** /**
* @return Sender|null * @return Sender|null
*/ */
public function getSenderAddress() public function getSenderAddress(): ?Sender
{ {
return $this->senderAddress; return $this->senderAddress;
} }
@ -464,7 +464,7 @@ abstract class Request implements RequestInterface
/** /**
* @return string|null * @return string|null
*/ */
public function getSenderAddressType() public function getSenderAddressType(): ?string
{ {
return $this->getSenderAddress() && $this->getSenderAddress()->get() ? $this->senderAddressType : null; return $this->getSenderAddress() && $this->getSenderAddress()->get() ? $this->senderAddressType : null;
} }
@ -478,7 +478,7 @@ abstract class Request implements RequestInterface
RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC => RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC, RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC => RequestInterface::SENDERADDRESSTYPE_ALPHANUMERIC,
RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL => RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL, RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL => RequestInterface::SENDERADDRESSTYPE_INTERNATIONAL,
RequestInterface::SENDERADDRESSTYPE_NATIONAL => RequestInterface::SENDERADDRESSTYPE_NATIONAL, RequestInterface::SENDERADDRESSTYPE_NATIONAL => RequestInterface::SENDERADDRESSTYPE_NATIONAL,
RequestInterface::SENDERADDRESSTYPE_SHORTCODE => RequestInterface::SENDERADDRESSTYPE_SHORTCODE RequestInterface::SENDERADDRESSTYPE_SHORTCODE => RequestInterface::SENDERADDRESSTYPE_SHORTCODE,
]; ];
} }
@ -497,7 +497,7 @@ abstract class Request implements RequestInterface
/** /**
* @return int|null * @return int|null
*/ */
public function getValidityPeriode() public function getValidityPeriode(): ?int
{ {
return $this->validityPeriode; return $this->validityPeriode;
} }
@ -523,6 +523,7 @@ abstract class Request implements RequestInterface
/** /**
* @param Client $client * @param Client $client
* @return Request
*/ */
public function setClient(Client $client): Request public function setClient(Client $client): Request
{ {

View File

@ -72,7 +72,7 @@ abstract class Response implements ResponseInterface
/** /**
* @return string|null * @return string|null
*/ */
public function getClientMessageId() public function getClientMessageId(): ?string
{ {
return $this->getContent()[self::CLIENTMESSAGEID]; return $this->getContent()[self::CLIENTMESSAGEID];
} }
@ -80,13 +80,13 @@ abstract class Response implements ResponseInterface
/** /**
* @return string|null * @return string|null
*/ */
public function getTransferId() public function getTransferId(): ?string
{ {
return $this->getContent()[self::TRANSFERID]; return $this->getContent()[self::TRANSFERID];
} }
/** /**
* @return string|null * @return int
*/ */
public function getSmsCount(): int public function getSmsCount(): int
{ {

View File

@ -36,7 +36,7 @@ class BinaryRequest extends Request implements SmsRequestInterface
return array_merge( return array_merge(
parent::getRawBody(), parent::getRawBody(),
[ [
'userDataHeaderPresent' => true 'userDataHeaderPresent' => true,
] ]
); );
} }

View File

@ -20,21 +20,15 @@ use D3\LinkmobilityClient\ValueObject\SmsBinaryMessage;
use D3\LinkmobilityClient\ValueObject\SmsTextMessage; use D3\LinkmobilityClient\ValueObject\SmsTextMessage;
use Phlib\SmsLength\SmsLength; use Phlib\SmsLength\SmsLength;
class RequestFactory class RequestFactory implements RequestFactoryInterface
{ {
/**
* @deprecated is SmsLength constant from version 2.1
*/
public const GSM_7BIT = '7-bit';
/**
* @deprecated is SmsLength constant from version 2.1
*/
public const GSM_UCS2 = 'ucs-2';
protected $message; protected $message;
protected $client; protected $client;
/**
* @param $message
* @param Client $client
*/
public function __construct($message, Client $client) public function __construct($message, Client $client)
{ {
$this->message = $message; $this->message = $message;
@ -46,7 +40,7 @@ class RequestFactory
*/ */
public function getSmsRequest(): SmsRequestInterface public function getSmsRequest(): SmsRequestInterface
{ {
if ($this->getSmsLength()->getEncoding() === self::GSM_7BIT) { if ($this->getSmsLength()->getEncoding() === SmsLength::ENCODING_7BIT) {
$message = new SmsTextMessage($this->message); $message = new SmsTextMessage($this->message);
return new TextRequest($message, $this->client); return new TextRequest($message, $this->client);
} }

View File

@ -15,9 +15,11 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS; namespace D3\LinkmobilityClient\SMS;
use D3\LinkmobilityClient\Client;
interface RequestFactoryInterface interface RequestFactoryInterface
{ {
public function __construct($message); public function __construct($message, Client $client);
public function getRequest(): SmsRequestInterface; public function getSmsRequest(): SmsRequestInterface;
} }

View File

@ -15,6 +15,8 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\SMS; namespace D3\LinkmobilityClient\SMS;
class Response extends \D3\LinkmobilityClient\Response\Response use D3\LinkmobilityClient\Response\Response as BaseResponse;
class Response extends BaseResponse
{ {
} }

View File

@ -30,7 +30,7 @@ class Url implements UrlInterface
/** /**
* @return string * @return string
*/ */
public function getTextSmsUri() public function getTextSmsUri(): string
{ {
return '/rest/smsmessaging/text'; return '/rest/smsmessaging/text';
} }
@ -38,7 +38,7 @@ class Url implements UrlInterface
/** /**
* @return string * @return string
*/ */
public function getBinarySmsUri() public function getBinarySmsUri(): string
{ {
return '/rest/smsmessaging/binary'; return '/rest/smsmessaging/binary';
} }

View File

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

View File

@ -30,7 +30,7 @@ class Recipient extends StringValueObject
*/ */
protected $allowedNumberTypes = [ protected $allowedNumberTypes = [
PhoneNumberType::MOBILE, PhoneNumberType::MOBILE,
PhoneNumberType::FIXED_LINE_OR_MOBILE PhoneNumberType::FIXED_LINE_OR_MOBILE,
]; ];
/** /**
@ -86,7 +86,7 @@ class Recipient extends StringValueObject
return $this->countryCode; return $this->countryCode;
} }
public function getFormatted() public function getFormatted(): string
{ {
return ltrim(parent::getFormatted(), '+'); return ltrim(parent::getFormatted(), '+');
} }

View File

@ -27,11 +27,11 @@ use libphonenumber\PhoneNumberUtil;
class Sender extends ValueObject class Sender extends ValueObject
{ {
/** /**
* @param string $number * @param string|null $number
* @param string $iso2CountryCode * @param string|null $iso2CountryCode
* *
* @throws RecipientException
* @throws NumberParseException * @throws NumberParseException
* @throws RecipientException
*/ */
public function __construct(string $number = null, string $iso2CountryCode = null) public function __construct(string $number = null, string $iso2CountryCode = null)
{ {
@ -67,7 +67,7 @@ class Sender extends ValueObject
return PhoneNumberUtil::getInstance(); return PhoneNumberUtil::getInstance();
} }
public function getFormatted() public function getFormatted(): string
{ {
return ltrim(parent::getFormatted(), '+'); return ltrim(parent::getFormatted(), '+');
} }

View File

@ -43,6 +43,9 @@ abstract class SmsMessageAbstract extends StringValueObject implements SmsMessag
return $this->getSmsLength()->getSize(); return $this->getSmsLength()->getSize();
} }
/**
* @return mixed
*/
public function getMessageContent() public function getMessageContent()
{ {
return $this->get(); return $this->get();

View File

@ -15,8 +15,6 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\ValueObject; namespace D3\LinkmobilityClient\ValueObject;
use Assert\Assert;
abstract class StringValueObject extends ValueObject abstract class StringValueObject extends ValueObject
{ {
public function __toString() public function __toString()

View File

@ -33,7 +33,7 @@ abstract class ValueObject
return $this->value; return $this->value;
} }
public function getFormatted() public function getFormatted(): string
{ {
return $this->get(); return $this->get();
} }