-
Notifications
You must be signed in to change notification settings - Fork 10
Enhance Android SMS Gateway PHP client with new entities and API methods #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis update introduces extensive enhancements to the Android SMS Gateway PHP client. It adds new domain entities, builder classes for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Client
participant Server
User->>Client: Build Message via MessageBuilder
User->>Client: SendMessage(message)
Client->>Server: POST /3rdparty/v1/messages
Server-->>Client: MessageState
Client-->>User: MessageState
User->>Client: ListDevices()
Client->>Server: GET /3rdparty/v1/devices
Server-->>Client: [Device, ...]
Client-->>User: [Device, ...]
User->>Client: GetLogs(from, to)
Client->>Server: GET /3rdparty/v1/logs?from=...&to=...
Server-->>Client: [LogEntry, ...]
Client-->>User: [LogEntry, ...]
User->>Client: RegisterWebhook(webhook)
Client->>Server: POST /3rdparty/v1/webhooks
Server-->>Client: Webhook
Client-->>User: Webhook
sequenceDiagram
participant User
participant SettingsBuilder
participant Client
participant Server
User->>SettingsBuilder: setEncryption(...), setGateway(...), ...
User->>SettingsBuilder: build()
SettingsBuilder-->>User: Settings
User->>Client: UpdateSettings(settings)
Client->>Server: PUT /3rdparty/v1/settings
Server-->>Client: object
Client-->>User: object
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (8)
tests/Domain/SettingsBuilderTest.php (1)
9-16: Consider expanding test coverage for the builder pattern.While the current test verifies basic builder functionality, consider adding tests for:
- Building with individual setter methods
- Method chaining verification
- Building with all possible parameters set
- Edge cases and validation
Example additional test:
public function testBuildWithAllParameters(): void { $settings = (new SettingsBuilder()) ->withEncryption((object)['enabled' => true]) ->withGateway((object)['host' => 'example.com']) ->build(); $this->assertInstanceOf(Settings::class, $settings); $obj = $settings->ToObject(); $this->assertObjectHasProperty('encryption', $obj); $this->assertObjectHasProperty('gateway', $obj); }src/Domain/Settings.php (1)
10-63: LGTM! Well-structured domain class with room for type safety improvements.The Settings class follows good domain modeling patterns with proper serialization support and clean constructor design. The conditional property inclusion in
ToObject()is efficient for API payloads.Consider these improvements for better type safety and usability:
- Add getter methods for property access:
public function getEncryption(): ?object { return $this->encryption; } public function getGateway(): ?object { return $this->gateway; } // ... etc
- Consider more specific types instead of generic
object:private ?EncryptionSettings $encryption; private ?GatewaySettings $gateway;
- Add validation in constructor or setters if the objects have expected structure.
README.md (1)
67-95: Well-organized API documentation structure.The categorization of client methods into logical groups (Message, Device, System, Settings, Webhook) makes the API much more discoverable and easier to navigate. The deprecation notices for old methods are clearly marked.
Minor formatting inconsistency: Consider using consistent list formatting throughout. The static analysis suggests using dashes instead of asterisks for unordered lists, but this is a minor stylistic choice.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~70-~70: Loose punctuation mark.
Context: ...ssage. *SendMessage(Message $message): Send a new SMS message. * `GetState(str...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~72-~72: Loose punctuation mark.
Context: ... its ID. *GetMessageState(string $id): Retrieve the state of a previously sent...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~76-~76: Loose punctuation mark.
Context: .... ### Device Methods *ListDevices(): List all registered devices. * `RemoveD...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...ed devices. *RemoveDevice(string $id): Remove a device by ID. ### System Meth...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~81-~81: Loose punctuation mark.
Context: .... ### System Methods *HealthCheck(): Check system health. * `RequestInboxExp...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ... *RequestInboxExport(object $request): Request inbox messages export. * `GetLo...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...tring $from = null, ?string $to = null)`: Get logs within a specified time range....(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~87-~87: Loose punctuation mark.
Context: ... ### Settings Methods *GetSettings(): Get user settings. * `UpdateSettings(ob...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~88-~88: Loose punctuation mark.
Context: ...gs. *UpdateSettings(object $settings): Update user settings. * `PatchSettings(...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~89-~89: Loose punctuation mark.
Context: ...ngs. *PatchSettings(object $settings): Partially update user settings. ### We...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~93-~93: Loose punctuation mark.
Context: ... ### Webhook Methods *ListWebhooks(): List all registered webhooks. * `Regist...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~94-~94: Loose punctuation mark.
Context: ...ks. *RegisterWebhook(object $webhook): Register a new webhook. * `DeleteWebhoo...(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~95-~95: Loose punctuation mark.
Context: ...w webhook. *DeleteWebhook(string $id): Delete a webhook by ID. # Contributing...(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
69-69: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
70-70: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
71-71: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
72-72: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
76-76: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
77-77: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
81-81: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
82-82: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
83-83: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
87-87: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
88-88: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
89-89: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
93-93: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
94-94: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
95-95: Unordered list style
Expected: dash; Actual: asterisk(MD004, ul-style)
src/Domain/MessagesExportRequest.php (1)
10-58: Clean domain class implementation following established patterns.The class correctly implements
SerializableInterfacewith proper constructor, factory method, and serialization. The structure is consistent with other domain classes in the codebase.Consider adding input validation for date format and device ID if these have specific requirements:
public function __construct(string $deviceId, string $since, string $until) { + if (empty($deviceId)) { + throw new \InvalidArgumentException('Device ID cannot be empty'); + } $this->deviceId = $deviceId; $this->since = $since; $this->until = $until; }src/Domain/SettingsBuilder.php (1)
5-5: Remove unused import.The
InvalidArgumentExceptionimport is not used in this class.-use InvalidArgumentException;src/Domain/MessageBuilder.php (1)
36-36: Remove extra blank line.There's an unnecessary blank line that should be removed for consistency.
private bool $withDeliveryReport = true; - /**src/Enums/WebhookEvent.php (1)
12-20: Consider moving the_ALL_constant to the top of the class for better readability.While PHP allows forward references to class constants, it's more conventional and clearer to define constants before they're used. This improves code readability and makes the validation logic easier to follow.
final class WebhookEvent { public const SMS_RECEIVED = 'sms:received'; public const SMS_SENT = 'sms:sent'; public const SMS_DELIVERED = 'sms:delivered'; public const SMS_FAILED = 'sms:failed'; public const SYSTEM_PING = 'system:ping'; + private const _ALL_ = [ + self::SMS_RECEIVED, + self::SMS_SENT, + self::SMS_DELIVERED, + self::SMS_FAILED, + self::SYSTEM_PING, + ]; + private string $value; private function __construct(string $value) {And remove the constant definition from lines 54-60.
Also applies to: 54-60
tests/ClientTest.php (1)
303-305: Remove unnecessary empty line.public function testPatchSettings(): void { - - $settings = new Settings(
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
README.md(2 hunks)src/Client.php(4 hunks)src/Domain/Device.php(1 hunks)src/Domain/LogEntry.php(1 hunks)src/Domain/Message.php(3 hunks)src/Domain/MessageBuilder.php(1 hunks)src/Domain/MessagesExportRequest.php(1 hunks)src/Domain/RecipientState.php(1 hunks)src/Domain/Settings.php(1 hunks)src/Domain/SettingsBuilder.php(1 hunks)src/Domain/Webhook.php(1 hunks)src/Enums/WebhookEvent.php(1 hunks)tests/ClientTest.php(7 hunks)tests/Domain/MessageBuilderTest.php(1 hunks)tests/Domain/MessageTest.php(1 hunks)tests/Domain/SettingsBuilderTest.php(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
tests/Domain/MessageBuilderTest.php (1)
src/Domain/MessageBuilder.php (8)
MessageBuilder(10-170)build(154-169)setId(67-70)setTtl(89-92)setSimNumber(100-103)setWithDeliveryReport(111-114)setPriority(132-135)setValidUntil(143-146)
src/Enums/WebhookEvent.php (1)
src/Domain/Webhook.php (1)
__construct(38-48)
src/Client.php (7)
src/Domain/Device.php (2)
Device(10-149)FromObject(69-78)src/Domain/LogEntry.php (3)
LogEntry(10-140)Message(109-111)FromObject(69-78)src/Domain/Webhook.php (2)
Webhook(11-110)FromObject(54-61)src/Domain/MessagesExportRequest.php (2)
MessagesExportRequest(10-59)FromObject(41-47)src/Domain/Settings.php (2)
Settings(10-112)FromObject(69-78)src/Domain/Message.php (2)
Message(11-118)Encrypt(80-92)src/Domain/MessageState.php (2)
MessageState(11-120)FromObject(108-119)
🪛 LanguageTool
README.md
[uncategorized] ~70-~70: Loose punctuation mark.
Context: ...ssage. * SendMessage(Message $message): Send a new SMS message. * `GetState(str...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~72-~72: Loose punctuation mark.
Context: ... its ID. * GetMessageState(string $id): Retrieve the state of a previously sent...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~76-~76: Loose punctuation mark.
Context: .... ### Device Methods * ListDevices(): List all registered devices. * `RemoveD...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...ed devices. * RemoveDevice(string $id): Remove a device by ID. ### System Meth...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~81-~81: Loose punctuation mark.
Context: .... ### System Methods * HealthCheck(): Check system health. * `RequestInboxExp...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~82-~82: Loose punctuation mark.
Context: ... * RequestInboxExport(object $request): Request inbox messages export. * `GetLo...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...tring $from = null, ?string $to = null)`: Get logs within a specified time range....
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~87-~87: Loose punctuation mark.
Context: ... ### Settings Methods * GetSettings(): Get user settings. * `UpdateSettings(ob...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~88-~88: Loose punctuation mark.
Context: ...gs. * UpdateSettings(object $settings): Update user settings. * `PatchSettings(...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~89-~89: Loose punctuation mark.
Context: ...ngs. * PatchSettings(object $settings): Partially update user settings. ### We...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~93-~93: Loose punctuation mark.
Context: ... ### Webhook Methods * ListWebhooks(): List all registered webhooks. * `Regist...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~94-~94: Loose punctuation mark.
Context: ...ks. * RegisterWebhook(object $webhook): Register a new webhook. * `DeleteWebhoo...
(UNLIKELY_OPENING_PUNCTUATION)
[uncategorized] ~95-~95: Loose punctuation mark.
Context: ...w webhook. * DeleteWebhook(string $id): Delete a webhook by ID. # Contributing...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
README.md
69-69: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
70-70: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
71-71: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
72-72: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
76-76: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
77-77: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
81-81: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
82-82: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
83-83: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
87-87: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
88-88: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
89-89: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
93-93: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
94-94: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
95-95: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
🪛 GitHub Check: build-test (8.0)
src/Domain/LogEntry.php
[failure] 55-55:
Deprecated in PHP 8.1: Required parameter $createdAt follows optional parameter $context.
tests/ClientTest.php
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
🪛 GitHub Check: build-test (8.1)
src/Domain/LogEntry.php
[failure] 55-55:
Deprecated in PHP 8.1: Required parameter $createdAt follows optional parameter $context.
tests/ClientTest.php
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
🪛 GitHub Check: build-test (7.4)
src/Domain/LogEntry.php
[failure] 55-55:
Deprecated in PHP 8.1: Required parameter $createdAt follows optional parameter $context.
tests/ClientTest.php
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
🔇 Additional comments (22)
src/Domain/RecipientState.php (1)
13-13: LGTM! Documentation enhancement improves clarity.The clarification that the phone number property can hold either the actual phone number or its hash accurately reflects the class's functionality, especially considering the
Decryptmethod. This improves API documentation clarity.tests/Domain/MessageTest.php (1)
54-54:Details
✅ Verification successful
Verify alignment with Message class implementation.
The change from testing
ttltoisEncryptedreflects the evolution of the Message domain model to include encryption state tracking. The assertion that messages are not encrypted by default is reasonable.Please verify that the Message class's
ToObject()method now includes theisEncryptedproperty and that this change doesn't break existing functionality:
🏁 Script executed:
#!/bin/bash # Description: Verify Message class ToObject method includes isEncrypted property # Expected: Find ToObject method implementation with isEncrypted property ast-grep --pattern 'class Message { $$$ public function ToObject() { $$$ } $$$ }'Length of output: 95
🏁 Script executed:
#!/bin/bash # Locate Message class definition echo "=== class Message definitions ===" rg -n "^\s*class\s\+Message\b" # Locate ToObject method echo "=== ToObject method definitions ===" rg -n "function\s\+ToObject\b" # Search for isEncrypted occurrences echo "=== isEncrypted occurrences ===" rg -n "isEncrypted"Length of output: 1302
Confirmed: Message class
ToObject()includesisEncryptedpropertyThe
ToObject()method insrc/Domain/Message.phpmaps$this->isEncryptedto'isEncrypted'(around line 100), and the default value is set tofalse(line 37). This aligns with the new test assertion that messages are not encrypted by default.No further changes required.
src/Domain/Settings.php (2)
83-111: Efficient serialization implementation.The
ToObject()method efficiently handles conditional property inclusion, avoiding null properties in the serialized output. This is good for API payload optimization.
69-78: Robust deserialization with null coalescing.The
FromObject()method properly handles missing properties using null coalescing, making it resilient to incomplete input data.README.md (1)
20-44: Excellent documentation of the builder pattern!The updated usage example clearly demonstrates how to use the new
MessageBuilderclass with method chaining for optional parameters. This is much more readable and flexible than the previous direct constructor approach.tests/Domain/MessageBuilderTest.php (1)
1-59: Comprehensive test coverage for MessageBuilder!The test suite covers all critical aspects:
- ✅ Minimal parameter building
- ✅ All optional parameters
- ✅ Validation logic (ttl/validUntil conflict)
- ✅ Method chaining behavior
The tests are well-structured with proper assertions and exception handling. This provides good confidence in the MessageBuilder functionality.
src/Domain/Message.php (3)
43-50: Good addition of new properties with proper documentation.The new
priorityandvalidUntilproperties are well-documented and follow the existing code style.
65-67: Excellent validation logic!The mutual exclusivity validation between
ttlandvalidUntilprevents invalid parameter combinations and provides a clear error message.
95-116: Smart conditional serialization approach.The
ToObjectmethod now conditionally includes optional properties only when they have values, which produces cleaner serialized objects and maintains backward compatibility.src/Domain/LogEntry.php (2)
83-97: Well-implemented conditional serialization.The conditional inclusion of the
contextproperty in the serialized object is a good approach, avoiding unnecessary null values in the output.
99-140: Clean and consistent getter methods.All getter methods follow consistent naming conventions and provide proper return type declarations.
src/Domain/SettingsBuilder.php (2)
47-105: Excellent builder pattern implementation.All setter methods consistently return
$thisenabling fluent interface, and the method signatures are well-documented with proper type hints.
112-121: Clean build method implementation.The build method correctly instantiates the Settings object with all configured properties.
src/Domain/Webhook.php (3)
38-48: Good constructor parameter ordering.The constructor properly places required parameters (
event,url) before optional ones (id,deviceId), following PHP best practices.
54-61: Excellent enum integration in factory method.The use of
WebhookEvent::FromValue()provides type safety when converting from generic objects, ensuring only valid webhook events are accepted.
66-81: Smart conditional serialization.The
ToObjectmethod only includes optional fields (id,deviceId) when they have values, keeping the serialized output clean and minimal.src/Domain/MessageBuilder.php (3)
56-59: Smart constructor design.Requiring the essential parameters (
messageandphoneNumbers) in the constructor while making everything else optional through setters is a good design choice.
154-169: Excellent validation logic in build method.The validation preventing simultaneous
ttlandvalidUntilsettings makes perfect business sense and provides clear error messaging.
67-146: Consistent fluent interface implementation.All setter methods properly return
$thisand follow consistent naming conventions, enabling clean method chaining.src/Domain/Device.php (1)
1-149: LGTM! Well-structured domain model.The
Deviceclass is well-implemented with:
- Proper encapsulation and immutability
- Comprehensive documentation
- Correct handling of nullable fields in serialization/deserialization
- Clear getter methods following consistent naming conventions
tests/ClientTest.php (1)
157-157: Consider whether type assertions are necessary given the type hints.Static analysis indicates that assertions like
assertIsObject()andassertIsArray()will always evaluate to true because the client methods already have return type declarations. While these assertions do provide documentation value and protection against future changes, you might consider whether they're necessary.If you decide to keep them for documentation purposes, consider adding a comment explaining why, or alternatively, test more specific properties of the returned objects/arrays.
Also applies to: 195-195, 219-219, 245-245, 268-268, 299-299, 332-332, 354-354, 379-379
🧰 Tools
🪛 GitHub Check: build-test (8.0)
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.🪛 GitHub Check: build-test (8.1)
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.🪛 GitHub Check: build-test (7.4)
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.src/Client.php (1)
1-414: Excellent implementation of the expanded client API!The client enhancements are well-designed:
- Smooth deprecation path for
Send→SendMessageandGetState→GetMessageState- Consistent implementation pattern across all new methods
- Proper error handling and type validation
- Clean integration with domain objects
- Good support for optional query parameters (e.g.,
skipPhoneValidation)The code maintains backward compatibility while significantly expanding the API surface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
README.md (1)
118-118: Fix table formatting per markdown standards.The table needs blank lines before and after it for proper markdown formatting.
+ | Category | Method | Description | | ------------ | ------------------------------------- | ------------------------ | | **Messages** | `SendMessage(Message $message)` | Send SMS message | | | `GetMessageState(string $id)` | Get message status by ID | | **Devices** | `ListDevices()` | List registered devices | | | `RemoveDevice(string $id)` | Remove device by ID | | **System** | `HealthCheck()` | Check API health status | | | `GetLogs(?string $from, ?string $to)` | Retrieve system logs | | **Settings** | `GetSettings()` | Get account settings | | | `UpdateSettings(object $settings)` | Update account settings | | **Webhooks** | `ListWebhooks()` | List registered webhooks | | | `RegisterWebhook(object $webhook)` | Register new webhook | | | `DeleteWebhook(string $id)` | Delete webhook by ID | +🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
118-118: Tables should be surrounded by blank lines
null(MD058, blanks-around-tables)
tests/ClientTest.php (1)
304-304: Remove extra blank lines.There are unnecessary blank lines in the
testPatchSettingsmethod.public function testPatchSettings(): void { - - $settings = new Settings(
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
README.md(1 hunks)src/Domain/LogEntry.php(1 hunks)src/Domain/SettingsBuilder.php(1 hunks)src/Enums/WebhookEvent.php(1 hunks)tests/ClientTest.php(7 hunks)tests/Domain/MessageBuilderTest.php(1 hunks)tests/Domain/SettingsBuilderTest.php(1 hunks)tests/EncryptorTest.php(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests/EncryptorTest.php
🚧 Files skipped from review as they are similar to previous changes (5)
- tests/Domain/SettingsBuilderTest.php
- tests/Domain/MessageBuilderTest.php
- src/Domain/SettingsBuilder.php
- src/Domain/LogEntry.php
- src/Enums/WebhookEvent.php
🧰 Additional context used
🪛 GitHub Check: build-test (8.1)
tests/ClientTest.php
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
🪛 GitHub Check: build-test (8.0)
tests/ClientTest.php
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
🪛 markdownlint-cli2 (0.17.2)
README.md
118-118: Tables should be surrounded by blank lines
null
(MD058, blanks-around-tables)
🔇 Additional comments (5)
README.md (2)
1-190: Excellent comprehensive documentation update!The README has been significantly improved with modern documentation practices, clear examples, and comprehensive API coverage. The structure is well-organized and user-friendly.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
118-118: Tables should be surrounded by blank lines
null(MD058, blanks-around-tables)
62-88:Details
✅ Verification successful
Verify the new MessageBuilder class and method names.
The documentation shows usage of
MessageBuilderclass and renamed methods (SendMessage/GetMessageState). Ensure these align with the actual implementation.
🏁 Script executed:
#!/bin/bash # Verify MessageBuilder class exists and has the documented methods ast-grep --pattern 'class MessageBuilder { $$$ }' # Verify Client class has the new method names ast-grep --pattern 'class Client { $$$ SendMessage($$$) { $$$ } $$$ }' ast-grep --pattern 'class Client { $$$ GetMessageState($$$) { $$$ } $$$ }'Length of output: 8944
🏁 Script executed:
#!/bin/bash # Locate Client class definition echo "Locating Client class definitions..." rg "class Client" -n # For each file containing Client, list its public methods for file in $(rg -l "class Client"); do echo -e "\nPublic methods in $file:" rg "public function" "$file" -n done # Search globally for the documented method names echo -e "\nSearching for SendMessage definitions..." rg "function SendMessage" -n echo -e "\nSearching for GetMessageState definitions..." rg "function GetMessageState" -n # Also check common camelCase variants echo -e "\nSearching for sendMessage definitions..." rg "function sendMessage" -n echo -e "\nSearching for getMessageState definitions..." rg "function getMessageState" -nLength of output: 3065
All documented classes and methods are present and correctly named
TheMessageBuilderfluent API and its.build()method exist insrc/Domain/MessageBuilder.php, andClient::SendMessage()andClient::GetMessageState()are implemented insrc/Client.phpexactly as shown in the README. No changes needed.tests/ClientTest.php (3)
3-3: Approve namespace change.The namespace change from
AndroidSmsGateway\Tests\DomaintoAndroidSmsGateway\Testsis appropriate and aligns with the test organization.
38-50: Approve method name updates.The test method renames (
testSend→testSendMessage,testGetState→testGetMessageState) correctly reflect the API changes in the Client class.Also applies to: 71-80
139-396: Excellent comprehensive test coverage for new API endpoints.The new test methods provide thorough coverage of all the new client functionality including device management, health checks, logs, settings, and webhooks.
🧰 Tools
🪛 GitHub Check: build-test (8.1)
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.🪛 GitHub Check: build-test (8.0)
[failure] 379-379:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 354-354:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Webhook> will always evaluate to true.
[failure] 332-332:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 299-299:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 268-268:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 245-245:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\LogEntry> will always evaluate to true.
[failure] 219-219:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 195-195:
Call to method PHPUnit\Framework\Assert::assertIsObject() with object will always evaluate to true.
[failure] 157-157:
Call to method PHPUnit\Framework\Assert::assertIsArray() with array<AndroidSmsGateway\Domain\Device> will always evaluate to true.
43b99ce to
dde1428
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
tests/ClientTest.php (1)
157-157: Remove redundant type assertion as noted in past review.The
assertIsArray()call is redundant sinceListDevices()has a strongly typed return type that guarantees an array.- $this->assertIsArray($devices); $this->assertCount(1, $devices);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
README.md(1 hunks)src/Client.php(4 hunks)src/Domain/Device.php(1 hunks)src/Domain/LogEntry.php(1 hunks)src/Domain/Message.php(3 hunks)src/Domain/MessageBuilder.php(1 hunks)src/Domain/MessagesExportRequest.php(1 hunks)src/Domain/RecipientState.php(1 hunks)src/Domain/Settings.php(1 hunks)src/Domain/SettingsBuilder.php(1 hunks)src/Domain/Webhook.php(1 hunks)src/Enums/WebhookEvent.php(1 hunks)tests/ClientTest.php(7 hunks)tests/Domain/MessageBuilderTest.php(1 hunks)tests/Domain/MessageTest.php(1 hunks)tests/Domain/SettingsBuilderTest.php(1 hunks)tests/EncryptorTest.php(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests/Domain/SettingsBuilderTest.php
🚧 Files skipped from review as they are similar to previous changes (13)
- src/Domain/RecipientState.php
- tests/Domain/MessageTest.php
- tests/EncryptorTest.php
- tests/Domain/MessageBuilderTest.php
- src/Domain/MessagesExportRequest.php
- src/Domain/Settings.php
- src/Enums/WebhookEvent.php
- src/Domain/Message.php
- src/Domain/SettingsBuilder.php
- src/Domain/Webhook.php
- src/Domain/LogEntry.php
- src/Domain/MessageBuilder.php
- src/Domain/Device.php
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/ClientTest.php (10)
src/Client.php (14)
Client(20-414)SendMessage(72-101)GetMessageState(124-142)ListDevices(150-165)RemoveDevice(173-180)HealthCheck(187-199)RequestInboxExport(207-220)GetLogs(229-253)GetSettings(260-272)ReplaceSettings(280-293)PatchSettings(301-314)ListWebhooks(321-336)RegisterWebhook(344-357)DeleteWebhook(365-372)src/Domain/Message.php (1)
Message(11-118)src/Domain/LogEntry.php (2)
Message(109-111)ID(102-104)src/Domain/MessagesExportRequest.php (1)
MessagesExportRequest(10-59)src/Domain/MessageState.php (3)
MessageState(11-120)State(69-71)ID(61-63)src/Domain/Settings.php (1)
Settings(10-112)src/Domain/Webhook.php (2)
Webhook(11-110)ID(86-88)src/Enums/ProcessState.php (2)
ProcessState(8-84)PENDING(29-31)src/Enums/WebhookEvent.php (2)
WebhookEvent(5-61)SMS_RECEIVED(30-32)src/Domain/Device.php (1)
ID(106-108)
🔇 Additional comments (15)
README.md (3)
119-134: Excellent API reference table structure.The API reference table provides a clear and organized overview of all client methods, categorized by functionality. This will greatly help developers understand the available endpoints.
162-168: Security-conscious encryption example.Good inclusion of encryption support example. The code demonstrates proper initialization of the
Encryptorclass with the client.
62-88:Details
✅ Verification successful
Verify the code example matches the actual API.
The usage example looks comprehensive and well-structured. However, please verify that the
MessageBuilderclass and its methods (setTtl,setSimNumber,setWithDeliveryReport,setPriority) are correctly implemented as shown in the example.
🏁 Script executed:
#!/bin/bash # Verify MessageBuilder class and its methods exist and match the documentation ast-grep --pattern $'class MessageBuilder { $$$ setTtl($_) { $$$ } $$$ setSimNumber($_) { $$$ } $$$ setWithDeliveryReport($_) { $$$ } $$$ setPriority($_) { $$$ } $$$ build() { $$$ } $$$ }'Length of output: 241
To locate and inspect the actual
MessageBuilderimplementation, let’s search for its definition and method signatures:
🏁 Script executed:
#!/bin/bash set -e # 1. Find where MessageBuilder is defined rg -n "class MessageBuilder" --color=never echo "----" # 2. List the methods we expect from the docs rg -n "function (setTtl|setSimNumber|setWithDeliveryReport|setPriority|build)" --color=neverLength of output: 823
MessageBuilder API Verified
I’ve confirmed that in src/Domain/MessageBuilder.php the following methods exist with signatures matching the README example:
public function setTtl(?int $ttl): selfpublic function setSimNumber(?int $simNumber): selfpublic function setWithDeliveryReport(bool $withDeliveryReport): selfpublic function setPriority(?int $priority): selfpublic function build(): MessageNo further changes are needed.
src/Client.php (6)
7-11: Clean import organization for new domain entities.The new import statements are well-organized and include all the necessary domain classes for the expanded API functionality.
49-63: Proper deprecation implementation.The deprecation of the
Sendmethod is handled correctly withtrigger_errorand delegation to the newSendMessagemethod. This maintains backward compatibility while encouraging migration to the new API.
72-101: Robust SendMessage implementation with query parameter support.The new
SendMessagemethod properly handles theskipPhoneValidationparameter and maintains the existing encryption logic. The query parameter construction is clean and secure.
109-116: Consistent deprecation pattern.The
GetStatemethod deprecation follows the same pattern asSend, maintaining consistency in the deprecation approach.
150-165: Well-implemented device listing with proper error handling.The
ListDevicesmethod correctly validates the response type and uses array mapping to convert objects toDeviceinstances. The static function approach is efficient.
229-253: Secure query parameter handling in GetLogs.The method properly handles optional query parameters and uses
http_build_queryfor safe URL encoding. The null parameter handling is clean and secure.tests/ClientTest.php (6)
3-3: Clean namespace organization.The namespace change from
AndroidSmsGateway\Tests\DomaintoAndroidSmsGateway\Testsprovides better organization for the test suite.
7-12: Comprehensive imports for expanded test coverage.The new import statements properly include all domain classes and enums needed for testing the expanded client functionality.
38-69: Well-structured test with proper assertions.The
testSendMessagemethod thoroughly validates the HTTP request details including method, path, headers, and response parsing. The test follows good patterns for mock setup and verification.
229-244: Excellent query parameter validation.The
testGetLogsmethod properly validates both the URL path and query parameters, ensuring proper URL encoding of the datetime values.
267-295: Comprehensive settings test with realistic data.The
testUpdateSettingsmethod creates a realisticSettingsobject with all properties and properly validates the PUT request behavior.
349-370: Well-designed webhook registration test.The test properly uses the
WebhookEventenum and validates the webhook creation process. The assertion on the response ID is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/Client.php (1)
260-272: Settings methods now return proper domain objects.The return type inconsistency issue from previous reviews has been correctly addressed. All settings methods now return
Settingsobjects instead of generic objects, improving type safety and API consistency.Also applies to: 280-292, 301-313
🧹 Nitpick comments (1)
src/Client.php (1)
187-199: Consider using domain objects for consistent API design.While the functionality is correct,
HealthCheckandRequestInboxExportreturn genericobjecttypes, which is inconsistent with other methods that return proper domain objects. Consider creating dedicated domain classes for these responses.Example for HealthCheck:
- public function HealthCheck(): object { + public function HealthCheck(): HealthStatus { // ... existing implementation ... - return $response; + return HealthStatus::FromObject($response); }Also applies to: 207-220
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Client.php(4 hunks)src/Domain/Settings.php(1 hunks)tests/ClientTest.php(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Domain/Settings.php
🔇 Additional comments (13)
src/Client.php (6)
7-11: LGTM: Clean domain imports.The new domain imports are well-organized and follow consistent naming conventions, supporting the expanded API functionality.
49-63: Proper deprecation handling implemented.The deprecated
Sendmethod correctly triggers a user deprecation warning and delegates to the new method, ensuring backward compatibility while guiding users toward the updated API.
65-101: Enhanced SendMessage method with query parameter support.The implementation correctly handles the optional
skipPhoneValidationparameter by building query parameters and appending them to the request path. The logic for conditional query string building is sound.
103-116: Consistent deprecation pattern for GetState method.The deprecation follows the same pattern as the
Sendmethod, maintaining consistency in the deprecation strategy.
150-165: Excellent array-to-domain-object mapping implementation.The
ListDevicesandListWebhooksmethods demonstrate proper handling of array responses with clean functional mapping to domain objects using static factory methods.Also applies to: 321-336
229-253: Robust query parameter handling in GetLogs.The method properly handles optional query parameters for date range filtering, with clean conditional logic for building the query string.
tests/ClientTest.php (7)
3-3: LGTM: Appropriate namespace update.The namespace change from
AndroidSmsGateway\Tests\DomaintoAndroidSmsGateway\Testsproperly reflects the test file's broader scope.
7-12: Clean import organization for new domain objects.The additional imports for
MessagesExportRequest,Settings,Webhook, andWebhookEventare well-organized and support the expanded test coverage.
38-69: Proper test method renaming maintains consistency.The renamed test methods
testSendMessageandtestGetMessageStatecorrectly align with the updated client method names while preserving comprehensive HTTP request verification.Also applies to: 71-90
139-159: Comprehensive array response testing.The tests for
ListDevicesandListWebhooksproperly verify both the HTTP request structure and the array-to-domain-object conversion, ensuring the mapping functionality works correctly.Also applies to: 327-347
220-244: Excellent query parameter testing.The
testGetLogsmethod thoroughly verifies query parameter encoding and URL construction, including proper URL encoding of datetime strings.
246-265: Complete settings API test coverage.The settings tests comprehensively cover GET, PUT, and PATCH operations with proper domain object verification, ensuring the Settings API functionality works end-to-end.
Also applies to: 267-295, 297-325
349-370: Webhook registration test uses proper enum.The test correctly demonstrates usage of the
WebhookEventenum, showing proper integration between domain objects and enums.
279775b to
b17670f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (13)
src/Client.php (3)
260-272: Excellent fix for settings return type.The
GetSettingsmethod now correctly returns aSettingsobject instead of a genericobject, addressing the previous review comment about type safety.
280-293: Excellent fix for settings replacement return type.The
ReplaceSettingsmethod now correctly returns aSettingsobject instead of a genericobject, addressing the previous review comment about consistency.
301-314: Excellent fix for settings patch return type.The
PatchSettingsmethod now correctly returns aSettingsobject instead of a genericobject, completing the type safety improvements for settings methods.tests/ClientTest.php (10)
139-159: Comprehensive device listing test coverage.The test properly verifies:
- HTTP method and path
- Authorization headers
- Response parsing to domain objects
- Array count and object properties
The redundant
assertIsArray()call mentioned in past reviews has been correctly removed.
176-195: Good health check test implementation.Tests the health endpoint properly and verifies response structure. The redundant
assertIsObject()call mentioned in past reviews has been correctly removed.
197-218: Solid inbox export request test.Properly tests the POST operation with domain object payload and response verification. The redundant assertion removal improves test clarity.
220-244: Excellent log retrieval test with query parameters.This test thoroughly verifies:
- Query parameter encoding in the URL
- Array response handling
- Domain object mapping
Good attention to detail in testing the query string construction.
246-265: Comprehensive settings retrieval test.Tests the settings endpoint and verifies the domain object properties. Clean test without redundant assertions.
267-295: Thorough settings replacement test.Good test coverage for the PUT operation with settings object payload and response verification.
297-325: Good settings patch test with partial data.Properly tests the PATCH operation using null values to represent partial updates, which is realistic for patch operations.
327-347: Solid webhook listing test.Comprehensive test coverage for webhook operations with proper domain object verification.
349-370: Excellent webhook registration test.Tests webhook creation with enum usage and proper response handling. Good integration of the
WebhookEventenum in testing.
372-385: Clean webhook deletion test.Properly tests the DELETE operation for webhooks with appropriate void handling.
🧹 Nitpick comments (2)
src/Client.php (2)
187-199: Consider creating a HealthCheck domain object for type safety.While the current implementation works, returning a generic
objectreduces type safety compared to other methods that return domain objects.Consider creating a
HealthCheckdomain object:public function HealthCheck(): HealthCheck { // ... existing code ... return HealthCheck::FromObject($response); }
207-220: Consider creating an ExportResult domain object.Similar to the health check, returning a generic
objectfor export requests reduces type consistency.Consider creating an
ExportResultorInboxExportResultdomain object for better type safety.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
README.md(1 hunks)src/Client.php(4 hunks)src/Domain/Device.php(1 hunks)src/Domain/LogEntry.php(1 hunks)src/Domain/Message.php(3 hunks)src/Domain/MessageBuilder.php(1 hunks)src/Domain/MessagesExportRequest.php(1 hunks)src/Domain/RecipientState.php(1 hunks)src/Domain/Settings.php(1 hunks)src/Domain/SettingsBuilder.php(1 hunks)src/Domain/Webhook.php(1 hunks)src/Enums/WebhookEvent.php(1 hunks)tests/ClientTest.php(7 hunks)tests/Domain/MessageBuilderTest.php(1 hunks)tests/Domain/MessageTest.php(1 hunks)tests/Domain/SettingsBuilderTest.php(1 hunks)tests/EncryptorTest.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (14)
- src/Domain/RecipientState.php
- tests/Domain/MessageTest.php
- tests/EncryptorTest.php
- tests/Domain/SettingsBuilderTest.php
- src/Domain/MessagesExportRequest.php
- tests/Domain/MessageBuilderTest.php
- src/Domain/Message.php
- src/Domain/Settings.php
- src/Enums/WebhookEvent.php
- src/Domain/SettingsBuilder.php
- src/Domain/Webhook.php
- src/Domain/LogEntry.php
- src/Domain/MessageBuilder.php
- src/Domain/Device.php
🔇 Additional comments (17)
README.md (1)
1-193: Excellent comprehensive documentation update!The README has been thoroughly modernized with clear structure, comprehensive examples, and detailed API reference. The documentation accurately reflects the new client methods and properly shows the transition from deprecated methods to their replacements.
Key improvements:
- Modern badges and professional formatting
- Clear table of contents and section organization
- Updated examples using
SendMessage()andGetMessageState()instead of deprecated methods- Comprehensive API reference documenting all new methods
- Security best practices and encryption support
- Detailed contributing guidelines
The code examples are accurate and demonstrate proper usage of the new
MessageBuilderclass and updated client API.src/Client.php (10)
7-11: Good domain object imports for expanded API coverage.The additional imports properly support the new API methods with appropriate domain objects for
Device,LogEntry,Webhook,MessagesExportRequest, andSettings.
49-63: Proper deprecation implementation for legacy method.The deprecated
Sendmethod correctly:
- Issues a user deprecation warning
- Delegates to the new
SendMessagemethod- Maintains backward compatibility
This follows PHP deprecation best practices.
72-101: Well-implemented replacement method with query parameter support.The new
SendMessagemethod properly:
- Handles the
skipPhoneValidationparameter via query string- Maintains encryption support
- Follows consistent error handling patterns
- Returns strongly-typed
MessageStateobject
109-142: Proper deprecation and replacement for GetState method.Similar to the
Sendmethod, this properly deprecates the old method and delegates to the newGetMessageStateimplementation with appropriate warnings.
150-165: Excellent device management implementation.The
ListDevicesmethod follows consistent patterns:
- Proper HTTP method (GET)
- Correct path construction
- Array response validation
- Domain object mapping using
Device::FromObject
173-180: Clean device removal implementation.The
RemoveDevicemethod correctly uses DELETE method and doesn't expect a response body, which is appropriate for deletion operations.
229-253: Well-implemented log retrieval with proper query handling.The
GetLogsmethod correctly:
- Handles optional date parameters
- Builds query string appropriately
- Maps response to
LogEntrydomain objects- Validates array response type
321-336: Solid webhook listing implementation.The webhook management follows the same consistent patterns as other list operations with proper domain object mapping.
344-357: Proper webhook registration with domain object return.The
RegisterWebhookmethod maintains consistency by returning aWebhookdomain object rather than a generic object.
365-372: Clean webhook deletion implementation.Follows the same pattern as
RemoveDevicewith appropriate void return type for deletion operations.tests/ClientTest.php (6)
3-3: Appropriate namespace change for test organization.The namespace change from
AndroidSmsGateway\Tests\DomaintoAndroidSmsGateway\Testsbetter reflects the scope of these client tests.
7-12: Good import additions for expanded test coverage.The new imports properly support testing of the expanded client API with domain objects and enums.
38-38: Method renamed to match updated client API.The test method name change from
testSendtotestSendMessagecorrectly reflects the new client method name.
71-71: Method renamed consistently.The test method name change from
testGetStatetotestGetMessageStatemaintains consistency with the client API updates.
111-115: Updated to use new client methods in integration test.The server test correctly uses the new
SendMessageandGetMessageStatemethods instead of the deprecated ones.
161-174: Thorough device removal test.Properly tests the DELETE operation with appropriate response handling for void return methods.
b17670f to
5846191
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
README.md (1)
159-167: Duplicate of Constructor Inconsistency
This example highlights passing anEncryptorto theClientconstructor, duplicating the mismatch flagged earlier. Ensure the API reference constructor snippet includes the encryptor parameter.
🧹 Nitpick comments (1)
README.md (1)
53-88: Consider Method Naming Consistency
The example uses PascalCase methods (SendMessage,GetMessageState), which diverges from the common PHP camelCase convention (e.g.,sendMessage). If this is intentional, please document the naming style choice; otherwise, consider refactoring to camelCase for PSR-12 alignment.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(1 hunks)
🔇 Additional comments (13)
README.md (13)
1-7: Header and Badges Look Good
Great job modernizing the title and adding clear, informative badges. The license, version, PHP requirement, and download count badges are accurate and well-formatted.
8-9: Description Is Clear and Concise
The one-liner effectively summarizes the library’s purpose and links to the API.
10-30: Verify Table of Contents Anchors
The TOC anchors include emojis and special characters (e.g., “📱” and trademark ™), which GitHub’s slugification may strip or alter. Please confirm that all links resolve correctly—especially the#-sms-gateway-for-android-php-api-clientand#️-prerequisitesanchors.
31-39: Features Section Approved
The bulleted feature list is succinct and highlights all key capabilities, including type safety and encryption.
40-46: Confirm Minimum PHP Version
The docs require PHP 7.4+, but strict typing and potential union types may demand PHP 8.0+. Please verify that PHP 7.4 is sufficient for all new features.
47-52: Installation Snippet Is Correct
Thecomposer requirecommand is accurate and the code fences are properly placed.
117-124: Core Methods Table Approved
The table clearly enumerates all endpoints and their descriptions.
135-143: Builder Methods Section Approved
The usage example forMessageBuilderis clear and matches the code changes.
146-154: Security Best Practices Approved
Credential handling advice and input validation tips are well-covered.
170-178: Contributing Guidelines Approved
Clear, actionable contribution steps make onboarding contributors straightforward.
180-184: Development Setup Section Approved
Cloning and installation instructions are concise and accurate.
186-188: License Section Approved
The Apache-2.0 reference is clear and the link is correct.
191-192: Trademark Note Approved
The trademark disclaimer is appropriate and correctly placed.
5846191 to
748e829
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
README.md (1)
92-104: Fix Unclosed Code Fence in Managing Devices example
The PHP snippet for “Managing Devices” begins withphp but lacks a closing. Add the closing backticks after line 103 to ensure proper Markdown rendering.
🧹 Nitpick comments (2)
README.md (2)
109-117: Refine Client constructor signature example
This block mixes PHP type hints and omits a comma after the$serverUrldefault. Consider simplifying to a real instantiation call or adjust it to a valid signature. For example:$client = new Client( $login, $password, 'https://api.sms-gate.app/3rdparty/v1', $httpClient = null, $encryptor = null );
163-169: Standardize default URL usage in encryption snippet
The encryption example callsnew Client($login, $password, Client::DEFAULT_URL, ...), while the signature example hardcodes the URL. Align on one approach (preferably theDEFAULT_URLconstant) for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
README.md(1 hunks)
🔇 Additional comments (6)
README.md (6)
1-7: Excellent header and badges update
The new title and badge set clearly convey project metadata (license, version, PHP requirements, downloads). Great first impression for newcomers.
8-8: Concise library description
The one-liner effectively summarizes capabilities and points to the official API.
33-39: Feature list is clear and comprehensive
The Features section neatly highlights key client capabilities and stands out visually.
49-51: Installation snippet is properly formatted
The Composer command and its Bash code fence are correct and easy to follow.
55-63: Quickstart “Sending an SMS” example is solid
The builder pattern usage and method calls are idiomatic and straightforward.
183-186: Verify repository clone URL
The development setup points togithub.com/android-sms-gateway/client-php.git, but the packagist package iscapcom6/android-sms-gateway. Please confirm the correct GitHub repository URL.
748e829 to
8f3447c
Compare
6aa9b3b to
73b5074
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
README.md (1)
15-15: Fix broken Prerequisites anchor linkThe TOC entry for Prerequisites uses
#️-prerequisiteswhich won't resolve to## ⚙️ Prerequisites. Update it to#-prerequisitesso the link works correctly.
🧹 Nitpick comments (1)
tests/ClientTest.php (1)
267-295: Consider testing edge cases for settings updatesWhile the test covers basic settings updates, consider adding tests for edge cases like partial updates with null values, invalid settings structures, or error responses from the API.
public function testPatchSettingsWithPartialData(): void { $settings = new Settings( new \stdClass(), null, // Test with null values null, null, null, null ); // Test with only one setting field updated // Verify that null fields are properly handled in serialization } public function testSettingsErrorHandling(): void { $responseMock = self::mockResponse( '{"error":"Invalid settings"}', 400, ['Content-Type' => 'application/json'] ); $this->mockClient->addResponse($responseMock); $this->expectException(\AndroidSmsGateway\Exceptions\HttpException::class); $this->client->ReplaceSettings($invalidSettings); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
README.md(1 hunks)src/Client.php(4 hunks)src/Domain/Device.php(1 hunks)src/Domain/LogEntry.php(1 hunks)src/Domain/Message.php(3 hunks)src/Domain/MessageBuilder.php(1 hunks)src/Domain/MessagesExportRequest.php(1 hunks)src/Domain/RecipientState.php(1 hunks)src/Domain/Settings.php(1 hunks)src/Domain/SettingsBuilder.php(1 hunks)src/Domain/Webhook.php(1 hunks)src/Enums/WebhookEvent.php(1 hunks)tests/ClientTest.php(7 hunks)tests/Domain/MessageBuilderTest.php(1 hunks)tests/Domain/MessageTest.php(1 hunks)tests/Domain/SettingsBuilderTest.php(1 hunks)tests/EncryptorTest.php(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tests/EncryptorTest.php
- tests/Domain/SettingsBuilderTest.php
🚧 Files skipped from review as they are similar to previous changes (12)
- src/Domain/RecipientState.php
- tests/Domain/MessageTest.php
- tests/Domain/MessageBuilderTest.php
- src/Domain/MessagesExportRequest.php
- src/Domain/SettingsBuilder.php
- src/Domain/MessageBuilder.php
- src/Domain/Settings.php
- src/Domain/Message.php
- src/Domain/Webhook.php
- src/Domain/LogEntry.php
- src/Enums/WebhookEvent.php
- src/Domain/Device.php
🔇 Additional comments (13)
README.md (3)
68-73: Excellent use of fluent interface in documentationThe example effectively demonstrates the builder pattern with method chaining for message configuration. This clearly shows the enhanced API capabilities and makes the library usage intuitive.
121-135: Comprehensive API reference enhances usabilityThe categorized method reference with descriptions provides excellent developer experience. The clear separation by functionality (Messages, Devices, System, Settings, Webhooks) makes the expanded API surface discoverable.
152-169: Strong security guidance for production usageThe security section appropriately emphasizes credential management, HTTPS usage, and includes practical examples for encryption support. This is crucial for SMS gateway integrations handling sensitive data.
src/Client.php (6)
56-63: Well-implemented deprecation strategyThe deprecation of the
Sendmethod includes proper user warnings and seamless delegation to the newSendMessagemethod. This provides a smooth migration path for existing users while maintaining backward compatibility.
72-88: Enhanced message sending with validation controlThe new
SendMessagemethod properly handles theskipPhoneValidationparameter through query string construction. The implementation correctly builds the query parameters and maintains the existing encryption flow.
229-253: Robust query parameter handling for logsThe
GetLogsmethod properly handles optional date range parameters and constructs query strings safely usinghttp_build_query. The conditional parameter building prevents empty query strings and maintains clean URLs.
260-272: Proper type safety in settings retrievalThe
GetSettingsmethod now correctly returns aSettingsdomain object instead of a generic object, addressing previous review feedback. This improves type safety and API consistency.
280-293: Consistent settings management methodsBoth
ReplaceSettingsandPatchSettingsnow properly returnSettingsobjects, providing type safety and consistency across the settings API. The use of appropriate HTTP verbs (PUT/PATCH) correctly reflects the semantic differences.Also applies to: 301-314
150-165:Details
❌ Incorrect review comment
Verify device ID validation
The
ListDevicesmethod correctly maps response objects toDevicedomain objects, but consider validating that device IDs are properly sanitized before use in URLs to prevent potential injection issues.
🏁 Script executed:
#!/bin/bash # Description: Check if device IDs are validated in the Domain classes # Expected: Device class should validate ID format or Client should sanitize IDs # Search for Device class implementation and ID validation ast-grep --pattern 'class Device { $$$ }' # Search for any ID validation or sanitization rg -A 5 -B 5 "ID.*validation|sanitize.*id|validate.*id" --type phpLength of output: 114
I couldn’t locate the
Deviceclass or any ID‐sanitization logic with the previous patterns. Let’s first find whereDeviceis defined and inspect itsFromObjectmethod:
🏁 Script executed:
#!/bin/bash # Find the Device class definition and its FromObject method echo "Searching for class Device definition..." rg --type php "class\s+Device" -n echo echo "Searching for Device::FromObject usage/definition..." rg --type php "FromObject" -nLength of output: 2096
Let’s inspect the
Device::FromObjectimplementation for any ID checks or sanitization:
🏁 Script executed:
#!/bin/bash # Show the FromObject method with some context rg -n -A20 -B3 "public static function FromObject" src/Domain/Device.phpLength of output: 750
Let’s check the
Deviceconstructor for any type hints or ID validation logic:
🏁 Script executed:
#!/bin/bash # Show Device::__construct implementation with surrounding context rg -n -A5 -B5 "public function __construct" src/Domain/Device.phpLength of output: 409
No ID Injection Risk in ListDevices
The
ListDevicesmethod always calls GET/deviceswithout interpolating any device ID into the URL, so there’s no opportunity for an injected ID here. ID sanitization should instead be implemented in any client methods that accept or embed device IDs in their paths (e.g.,GetDevice($id),DeleteDevice($id)).Likely an incorrect or invalid review comment.
tests/ClientTest.php (4)
38-50: Good test method renaming for API consistencyThe renaming of
testSendtotestSendMessageandtestGetStatetotestGetMessageStateproperly aligns the tests with the new non-deprecated method names, maintaining clear test documentation.Also applies to: 71-80
139-159: Comprehensive device management testingThe
testListDevicesmethod properly verifies HTTP method, path, authentication, and response parsing. The mock response includes realistic device data structure with all expected fields.
220-244: Excellent query parameter testingThe
testGetLogsmethod thoroughly validates query parameter encoding and URL construction, including proper URL encoding of datetime values. This ensures the date range filtering works correctly.
349-370: Strong webhook registration testingThe test properly uses the
WebhookEventenum and validates the complete request/response cycle for webhook registration, ensuring proper domain object handling.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
Tests