Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: (! contains(github.event.head_commit.message, '[ci skip]'))
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']
db-platforms: ['MySQLi', 'SQLite3']
mysql-versions: ['5.7']
dependencies: ['highest']
Expand All @@ -55,8 +55,8 @@ jobs:
# SQLSRV
- php-versions: '8.1'
db-platforms: SQLSRV
mysql-versions: '5.7'
dependencies: 'highest'
mysql-versions: '8.0'
dependencies: 'lowest'
# OCI8
- php-versions: '8.1'
db-platforms: OCI8
Expand Down Expand Up @@ -84,15 +84,18 @@ jobs:
options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3

mssql:
image: mcr.microsoft.com/mssql/server:2019-CU28-ubuntu-20.04
image: mcr.microsoft.com/mssql/server:2022-latest
env:
SA_PASSWORD: 1Secure*Password1
MSSQL_SA_PASSWORD: 1Secure*Password1
ACCEPT_EULA: Y
MSSQL_PID: Developer
MSSQL_ENCRYPT: optional
ports:
- 1433:1433
options: --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q 'SELECT @@VERSION' -N -C" --health-interval=10s --health-timeout=5s --health-retries=3
options: >-
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -C -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q 'SELECT @@VERSION'"
--health-interval=10s
--health-timeout=5s
--health-retries=3

oracle:
image: gvenzl/oracle-xe:18
Expand All @@ -109,6 +112,22 @@ jobs:
--health-retries 10

steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: true

- name: Create database for MSSQL Server
if: matrix.db-platforms == 'SQLSRV'
run: sqlcmd -S 127.0.0.1 -U sa -P 1Secure*Password1 -Q "CREATE DATABASE test"
Expand Down Expand Up @@ -147,7 +166,7 @@ jobs:
COMPOSER_UPDATE_FLAGS: ${{ matrix.dependencies == 'lowest' && '--prefer-lowest' || '' }}

- name: Test with PHPUnit
run: vendor/bin/phpunit --debug --coverage-text --testsuite main
run: vendor/bin/phpunit --coverage-text --testsuite main
env:
DB: ${{ matrix.db-platforms }}
TERM: xterm-256color
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"codeigniter4/framework": "^4.2.7",
"mikey179/vfsstream": "^1.6.7",
"mockery/mockery": "^1.0",
"rector/rector": "1.2.8"
"rector/rector": "^2.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
'CodeIgniter SMSRocket',
'Pooya Parsa Dadashi',
'[email protected]'
'[email protected]',
);
26 changes: 5 additions & 21 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@

$ignoreErrors = [];

$ignoreErrors[] = [
'message' => '#^Access to an undefined property hasProperty\\(Status\\)\\:\\:\\$Data\\.$#',
'count' => 3,
'path' => __DIR__ . '/src/Drivers/AmootsmsDriver.php',
];

$ignoreErrors[] = [
'message' => '#^Access to an undefined property hasProperty\\(status\\)\\:\\:\\$data\\.$#',
'count' => 3,
'path' => __DIR__ . '/src/Drivers/IdehpardazanDriver.php',
];
$ignoreErrors[] = [
'message' => '#^Access to an undefined property hasProperty\\(status\\)\\:\\:\\$data\\.$#',
'count' => 2,
'path' => __DIR__ . '/src/Drivers/FarazsmsDriver.php',
];
$ignoreErrors[] = [
'message' => '#Access to an undefined property hasProperty\(sid\)::\$status.#',
'count' => 1,
'path' => __DIR__ . '/src/Drivers/TwilioDriver.php',
];
// $ignoreErrors[] = [
// 'message' => '#^Access to an undefined property hasProperty\\(Status\\)\\:\\:\\$Data\\.$#',
// 'count' => 3,
// 'path' => __DIR__ . '/src/Drivers/AmootsmsDriver.php',
// ];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="false"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src/" />
Expand Down
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

TypedPropertyFromAssignsRector::class => [
__DIR__ . '/src/Models/SMSLogModel.php',

__DIR__ . '/tests/_support/DatabaseTestCase.php',
__DIR__ . '/tests/_support/Config/Registrar.php',
],
]);
Expand Down
39 changes: 20 additions & 19 deletions src/Enums/Amootsms/DeliveryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
*/
enum DeliveryStatus: int
{
case SendToTci = 0;
case RecievedPhone = 1;
case NotRecievedPhone = 2;
case TciError = 3;
case UnknownError = 5;
case TciReceived = 8;
case NotTciReceived = 16;
case BlackList = 35;
case Unknown = 100;
case Sent = 200;
case Filtered = 300;
case SendingList = 400;
case NoReceipt = 500;
case SendWithAvanak = 501;
case SendWithBackupVtel = 502;
case SendingQueue = 900;
case WrongNumber = 950;
case EmptyMessage = 951;
case ShortCodeInvalid = 952;

/**
* Get the delivery status title directly from the code.
*/
Expand Down Expand Up @@ -68,23 +88,4 @@ public static function fromCode(int|string $code): DeliveryStatus
default => self::Unknown, // Return Unknown as default if code is invalid
};
}
case SendToTci = 0;
case RecievedPhone = 1;
case NotRecievedPhone = 2;
case TciError = 3;
case UnknownError = 5;
case TciReceived = 8;
case NotTciReceived = 16;
case BlackList = 35;
case Unknown = 100;
case Sent = 200;
case Filtered = 300;
case SendingList = 400;
case NoReceipt = 500;
case SendWithAvanak = 501;
case SendWithBackupVtel = 502;
case SendingQueue = 900;
case WrongNumber = 950;
case EmptyMessage = 951;
case ShortCodeInvalid = 952;
}
14 changes: 7 additions & 7 deletions src/Enums/Farazsms/DeliveryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
*/
enum DeliveryStatus: int
{
case Delivered = 2;
case Discarded = 4;
case Pending = 1;
case Failed = 3;
case Send = 0;
case Unknown = 99; // Default status for unknown codes

/**
* Get the delivery status title directly from the code.
*/
Expand Down Expand Up @@ -54,11 +61,4 @@ public static function fromCode(int|string $code): DeliveryStatus
default => self::Unknown, // Return Unknown as default if code is invalid
};
}

case Delivered = 2;
case Discarded = 4;
case Pending = 1;
case Failed = 3;
case Send = 0;
case Unknown = 99; // Default status for unknown codes
}
18 changes: 9 additions & 9 deletions src/Enums/Idehpardazan/DeliveryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
*/
enum DeliveryStatus: int
{
case Recieved = 1;
case NotRecievedPhone = 2;
case RecievedToTci = 3;
case NotRecievedToTci = 4;
case RecievedToOperator = 5;
case Failed = 6;
case BlackList = 7;
case Unknown = 8;

/**
* Get the delivery status title directly from the code.
*/
Expand Down Expand Up @@ -57,13 +66,4 @@ public static function fromCode(int|string $code): DeliveryStatus
default => self::Unknown, // Return Unknown as default if code is invalid
};
}

case Recieved = 1;
case NotRecievedPhone = 2;
case RecievedToTci = 3;
case NotRecievedToTci = 4;
case RecievedToOperator = 5;
case Failed = 6;
case BlackList = 7;
case Unknown = 8;
}
29 changes: 15 additions & 14 deletions src/Enums/Twilio/DeliveryStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
*/
enum DeliveryStatus: string
{
case Queued = 'queued';
case Sending = 'sending';
case Sent = 'sent';
case Failed = 'failed';
case Delivered = 'delivered';
case Undelivered = 'undelivered';
case Receiving = 'receiving';
case Received = 'received';
case Accepted = 'accepted';
case Scheduled = 'scheduled';
case Read = 'read';
case PartiallyDelivered = 'partially_delivered';
case Canceled = 'canceled';
case Unknown = 'unknown';

/**
* Map status string to a numeric code for storage in database.
*/
Expand Down Expand Up @@ -113,18 +128,4 @@ public static function fromCode(string $code): DeliveryStatus
default => self::Unknown, // Return Unknown as default if code is invalid
};
}
case Queued = 'queued';
case Sending = 'sending';
case Sent = 'sent';
case Failed = 'failed';
case Delivered = 'delivered';
case Undelivered = 'undelivered';
case Receiving = 'receiving';
case Received = 'received';
case Accepted = 'accepted';
case Scheduled = 'scheduled';
case Read = 'read';
case PartiallyDelivered = 'partially_delivered';
case Canceled = 'canceled';
case Unknown = 'unknown';
}
2 changes: 1 addition & 1 deletion src/Responses/SMSResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
/**
* @var string|null The message ID of the SMS operation, or null if not available.
*/
protected ?string $messageId = null
protected ?string $messageId = null,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/ObfuscatesSensitiveDataTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function hideSensitive(string $message, ?array $customPatterns = null): s

// Iterate through each pattern and replace sensitive data with a masked version
foreach ($patterns as $pattern => $replacement) {
$message = preg_replace($pattern, $replacement, (string) $message);
$message = preg_replace($pattern, (string) $replacement, (string) $message);
}

return $message;
Expand Down
5 changes: 2 additions & 3 deletions tests/Drivers/AmootsmsDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@
final class AmootsmsDriverTest extends TestCase
{
private AmootsmsDriver $driver;
private MockObject $mockModel;
private MockObject $mockClient;

protected function setUp(): void
{
parent::setUp();
$this->mockModel = $this->createMock(SMSLogModel::class);
$mockModel = $this->createMock(SMSLogModel::class);
$this->mockClient = $this->createMock(CURLRequest::class);

$config = [
'token' => 'test-token',
];

$this->driver = new AmootsmsDriver($config, $this->mockModel, $this->mockClient);
$this->driver = new AmootsmsDriver($config, $mockModel, $this->mockClient);
}

public function testSendSuccess(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Drivers/FarazsmsDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ final class FarazsmsDriverTest extends TestCase
{
private FarazsmsDriver $driver;
private MockObject $client;
private MockObject $model;

protected function setUp(): void
{
$this->client = $this->createMock(CURLRequest::class);
$this->model = $this->createMock(SMSLogModel::class);
$model = $this->createMock(SMSLogModel::class);
$config = ['api_key' => 'test_api_key'];

$this->driver = new FarazsmsDriver($config, $this->model, $this->client);
$this->driver = new FarazsmsDriver($config, $model, $this->client);
}

public function testSendSuccess(): void
Expand Down
5 changes: 2 additions & 3 deletions tests/Drivers/IdehpardazanDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ final class IdehpardazanDriverTest extends CIUnitTestCase
{
private IdehpardazanDriver $driver;
private MockObject $client;
private MockObject $model;

protected function setUp(): void
{
parent::setUp();

// Mocking the CURLRequest and SMSLogModel
$this->client = $this->createMock(CURLRequest::class);
$this->model = $this->createMock(SMSLogModel::class);
$model = $this->createMock(SMSLogModel::class);

// Initialize IdehpardazanDriver with mocked dependencies
$this->driver = new IdehpardazanDriver(['api_key' => 'test-api-key'], $this->model, $this->client);
$this->driver = new IdehpardazanDriver(['api_key' => 'test-api-key'], $model, $this->client);
}

public function testSend(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Drivers/TwilioDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testSendSuccess(): void
DeliveryStatus::fromCode('sent')->toNumericCode(),
'Test message',
null,
'TestSender'
'TestSender',
);

$messageId = $this->driver->send('+1234567890', 'Test message', 'TestSender');
Expand Down
Loading
Loading