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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Category
*/
public function __construct(string $id, string $name)
{
if (empty($id) || empty($name)) {
if (trim($id) === '' || trim($name) === '') {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Consider adding test coverage for whitespace-only strings

The updated validation logic now rejects whitespace-only strings (e.g., ' '), but the existing tests in CategoryModelTest only cover completely empty strings ''. Adding test cases for whitespace-only inputs would ensure this bugfix is properly validated.

Example:

public function testWhitespaceOnlyCategoryId(): void
{
    $this->expectException(EmptyCategoryParameterException::class);
    new Category('   ', 'test');
}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (blocking): Values validated with trim() but stored untrimmed creates data inconsistency

The validation checks trim($id) === '' and trim($name) === '' but then stores the original values on lines 39-40 without trimming. This means strings like " test " will pass validation but be stored with leading/trailing whitespace, creating inconsistent data.

Consider trimming the values before storing them:

$this->id = trim($id);
$this->name = trim($name);

Copilot uses AI. Check for mistakes.
throw new EmptyCategoryParameterException(
new TranslatableLabel('No parameter can be an empty string.', 'general.errors.empty')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OrderStatus
*/
public function __construct(string $id, string $name)
{
if ($id === "" || empty($name)) {
if (trim($id) === '' || trim($name) === '') {
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Consider adding test coverage for whitespace-only strings

The updated validation logic now rejects whitespace-only strings (e.g., ' '), but the existing tests in OrderStatusModelTest only cover completely empty strings ''. Adding test cases for whitespace-only inputs would ensure this bugfix is properly validated.

Example:

public function testWhitespaceOnlyOrderStatusId(): void
{
    $this->expectException(EmptyOrderStatusParameterException::class);
    new OrderStatus('   ', 'test');
}

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (blocking): Values validated with trim() but stored untrimmed creates data inconsistency

The validation checks trim($id) === '' but then stores the original $id value on line 39 without trimming. This means strings like " test " will pass validation but be stored with leading/trailing whitespace, creating inconsistent data.

Consider trimming the values before storing them:

$this->id = trim($id);
$this->name = trim($name);

Copilot uses AI. Check for mistakes.
throw new EmptyOrderStatusParameterException(
new TranslatableLabel('No parameter can be an empty string.', 'general.errors.empty')
);
Expand Down