Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.0', '7.4', '8.0', '8.3']
version: ['7.1', '7.4', '8.0', '8.4']
max-parallel: 2

steps:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.0', '7.4', '8.0', '8.3']
version: ['7.1', '7.4', '8.0', '8.4']
max-parallel: 1

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A software development kit to provide ways to interact with CM.com's Text servic

### Requirements

- php 7.* or 8.0 or 8.1 or 8.2 or 8.3
- php 7.1 through 8.4 (inclusive)


## Usage
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cmdotcom/text-sdk-php",
"description": "PHP SDK to send messages with CM.com",
"type": "library",
"version": "2.3.1",
"version": "3.0.0",
"keywords": ["sms","cm.com","rcs","whatsapp","viber","line","wechat","imessage","twitter","instagram"],
"homepage": "https://www.cm.com/products/text/",
"license": "MIT",
Expand All @@ -16,10 +16,10 @@
"require": {
"ext-curl": "*",
"ext-json": "*",
"php": "^7.0||^8.0"
"php": "^7.1||^8.0"
},
"require-dev": {
"phpunit/phpunit": "~6.0||~9.0"
"phpunit/phpunit": "~7.0||~9.0"
},
"autoload": {
"psr-0": {
Expand Down
4 changes: 2 additions & 2 deletions src/CMText/ITextClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function __construct(
* @param string $message - Message body to send
* @param string $from - Sender name
* @param array $to - Recipient phonenumbers
* @param string $reference optional
* @param string|null $reference optional
*
* @return TextClientResult
*/
public function SendMessage(
string $message,
string $from,
array $to,
string $reference = null
?string $reference = null
);

/**
Expand Down
9 changes: 7 additions & 2 deletions src/CMText/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ class Message implements JsonSerializable
*
* @param string|MessageBody $body
* @param string|null $from
* @param array $to
* @param array|null $to
* @param string|null $reference
* @throws \CMText\Exceptions\RecipientLimitException
*/
public function __construct($body = '', string $from = null, array $to = [], string $reference = null)
public function __construct(
$body = '',
?string $from = null,
?array $to = [],
?string $reference = null
)
{
$this->__set('body', $body);
$this->__set('from', $from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class WhatsAppInteractiveContent implements \JsonSerializable
*/
public function __construct(
string $type,
WhatsAppInteractiveHeader $header = null,
WhatsAppInteractiveBody $body = null,
IWhatsAppInteractiveAction $action = null,
WhatsAppInteractiveFooter $footer = null
?WhatsAppInteractiveHeader $header = null,
?WhatsAppInteractiveBody $body = null,
?IWhatsAppInteractiveAction $action = null,
?WhatsAppInteractiveFooter $footer = null
)
{
if( !in_array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class WhatsAppInteractiveHeader

/**
* @param string $type
* @param string $text
* @param string|null $text
* @param MediaContent|null $media
* @throws \Exception
*/
public function __construct(
string $type,
string $text = null,
MediaContent $media = null)
?string $text = null,
?MediaContent $media = null)
{
if( !in_array($type, (new \ReflectionClass(WhatsAppInteractiveHeaderTypes::class))->getConstants()) ){
throw new \Exception("Unsupported WhatsApp-InteractiveHeader-type $type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WhatsAppInteractiveSectionRow
public function __construct(
string $title,
string $id,
string $description = null
?string $description = null
)
{
$this->title = $title;
Expand Down
2 changes: 1 addition & 1 deletion src/CMText/RichContent/Suggestions/ReplySuggestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ReplySuggestion extends SuggestionBase

public function __construct(
string $Label,
string $Text = null
?string $Text = null
)
{
$this->label = $Label;
Expand Down
4 changes: 2 additions & 2 deletions src/CMText/TextClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TextClient implements ITextClient
/**
* SDK Version constant
*/
const VERSION = '2.3.1';
const VERSION = '3.0.0';


/**
Expand Down Expand Up @@ -70,7 +70,7 @@ public function SendMessage(
string $message,
string $from,
array $to,
string $reference = null
?string $reference = null
)
{
// send it out instantly
Expand Down
4 changes: 2 additions & 2 deletions src/CMText/TextClientResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class TextClientResult
* TextClientResult constructor.
*
* @param int $httpStatusCode
* @param string $responseBody
* @param string|null $responseBody
*/
public function __construct(int $httpStatusCode, $responseBody = '')
public function __construct(int $httpStatusCode, ?string $responseBody = '')
{
$this->httpStatusCode = $httpStatusCode;
$this->response = $responseBody;
Expand Down
84 changes: 49 additions & 35 deletions tests/CMText/RichContent/Common/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,37 @@ public function testJsonSerialize()

public function testAddUrl()
{
$this->assertObjectHasAttribute(
'urls',
(new Contact(
$this->contactProperties['url']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['url']
))->jsonSerialize(),
'urls'
)
);
}

public function testAddPhonenumber()
{
$this->assertObjectHasAttribute(
'phones',
(new Contact(
$this->contactProperties['phonenumber']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['phonenumber']
))->jsonSerialize(),
'phones'
)
);
}

public function testSetOrganization()
{
$this->assertObjectHasAttribute(
'org',
(new Contact(
$this->contactProperties['organization']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['organization']
))->jsonSerialize(),
'org'
)
);
}

Expand Down Expand Up @@ -95,41 +101,49 @@ public function test__construct()

public function testSetBirthday()
{
$this->assertObjectHasAttribute(
'birthday',
(new Contact(
$this->contactProperties['birthday']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['birthday']
))->jsonSerialize(),
'birthday'
)
);
}

public function testSetName()
{
$this->assertObjectHasAttribute(
'name',
(new Contact(
$this->contactProperties['name']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['name']
))->jsonSerialize(),
'name'
)
);
}

public function testAddEmail()
{
$this->assertObjectHasAttribute(
'emails',
(new Contact(
$this->contactProperties['email']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['email']
))->jsonSerialize(),
'emails'
)
);
}

public function testAddAddress()
{
$this->assertObjectHasAttribute(
'addresses',
(new Contact(
$this->contactProperties['address']
))->jsonSerialize()
$this->assertTrue(
property_exists(
(new Contact(
$this->contactProperties['address']
))->jsonSerialize(),
'addresses'
)
);
}

Expand Down
15 changes: 6 additions & 9 deletions tests/CMText/RichContent/Common/LineItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ public function test__construct()

$json = json_decode(json_encode($lineitem));

$this->assertObjectHasAttribute(
'label',
$json
$this->assertTrue(
property_exists($json, 'label')
);

$this->assertObjectHasAttribute(
'type',
$json
$this->assertTrue(
property_exists($json, 'type')
);

$this->assertObjectHasAttribute(
'amount',
$json
$this->assertTrue(
property_exists($json, 'amount')
);
}
}
5 changes: 2 additions & 3 deletions tests/CMText/RichContent/Messages/PaymentMessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public function test__construct()

$json = json_decode(json_encode($message));

$this->assertObjectHasAttribute(
'payment',
$json
$this->assertTrue(
property_exists($json, 'payment')
);
}
}
Loading
Loading