Skip to content

South Asia Application Layer#45

Merged
zigzagdev merged 4 commits intofeature/south-asiafrom
feature/south-eas-asia-application
Aug 11, 2025
Merged

South Asia Application Layer#45
zigzagdev merged 4 commits intofeature/south-asiafrom
feature/south-eas-asia-application

Conversation

@zigzagdev
Copy link
Copy Markdown
Owner

What I have done

  • fix failed test
  • Create ListQuery
  • Create ListQuery Test

@zigzagdev zigzagdev requested a review from Copilot August 11, 2025 11:10
@zigzagdev zigzagdev self-assigned this Aug 11, 2025
@zigzagdev zigzagdev linked an issue Aug 11, 2025 that may be closed by this pull request

This comment was marked as outdated.

@zigzagdev zigzagdev requested a review from Copilot August 11, 2025 12:37
@zigzagdev zigzagdev merged commit f2aef60 into feature/south-asia Aug 11, 2025
@zigzagdev zigzagdev deleted the feature/south-eas-asia-application branch August 11, 2025 12:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new WorldHeritageListQuery data structure and its corresponding factory for handling World Heritage site data, along with comprehensive test coverage. The changes also include fixes to an existing test to ensure proper data isolation.

  • Creates a new query object pattern for World Heritage list operations
  • Implements factory pattern for building query objects with validation
  • Fixes existing test by implementing proper database cleanup and data seeding

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
WorldHeritageListQueryFactoryTest.php New comprehensive test suite for the factory with positive and negative test cases
GetWorldHeritageByIdUseCaseTest.php Updated existing test with proper database cleanup and corrected test data
WorldHeritageListQuery.php New immutable query object with getter methods and array conversion
WorldHeritageListQueryFactory.php New factory class with validation logic for building query objects

return new WorldHeritageListQuery(
id: Arr::get($request, 'id', null),
unesco_id: $request['unesco_id'],
official_name: (string)($request['official_name'] ?? ''),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to an empty string if it's falsy, which contradicts the validation that ensures it's not null. If official_name is required and validated as non-null, the fallback to empty string is unnecessary and could mask validation issues.

Suggested change
official_name: (string)($request['official_name'] ?? ''),
official_name: $request['official_name'],

Copilot uses AI. Check for mistakes.
id: Arr::get($request, 'id', null),
unesco_id: $request['unesco_id'],
official_name: (string)($request['official_name'] ?? ''),
name: (string)($request['name'] ?? ''),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to an empty string if it's falsy, which contradicts the validation that ensures it's not null. If name is required and validated as non-null, the fallback to empty string is unnecessary and could mask validation issues.

Suggested change
name: (string)($request['name'] ?? ''),
name: $request['name'],

Copilot uses AI. Check for mistakes.
unesco_id: $request['unesco_id'],
official_name: (string)($request['official_name'] ?? ''),
name: (string)($request['name'] ?? ''),
country: (string)($request['country'] ?? ''),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to an empty string if it's falsy, which contradicts the validation that ensures it's not null. If country is required and validated as non-null, the fallback to empty string is unnecessary and could mask validation issues.

Suggested change
country: (string)($request['country'] ?? ''),
country: $request['country'],

Copilot uses AI. Check for mistakes.
official_name: (string)($request['official_name'] ?? ''),
name: (string)($request['name'] ?? ''),
country: (string)($request['country'] ?? ''),
region: (string)($request['region'] ?? ''),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to an empty string if it's falsy, which contradicts the validation that ensures it's not null. If region is required and validated as non-null, the fallback to empty string is unnecessary and could mask validation issues.

Suggested change
region: (string)($request['region'] ?? ''),
region: (string)$request['region'],

Copilot uses AI. Check for mistakes.
name: (string)($request['name'] ?? ''),
country: (string)($request['country'] ?? ''),
region: (string)($request['region'] ?? ''),
category: (string)($request['category'] ?? ''),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to an empty string if it's falsy, which contradicts the validation that ensures it's not null. If category is required and validated as non-null, the fallback to empty string is unnecessary and could mask validation issues.

Suggested change
category: (string)($request['category'] ?? ''),
category: (string)$request['category'],

Copilot uses AI. Check for mistakes.
country: (string)($request['country'] ?? ''),
region: (string)($request['region'] ?? ''),
category: (string)($request['category'] ?? ''),
year_inscribed: (int)($request['year_inscribed'] ?? 0),
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This line casts the required field to 0 if it's falsy, which contradicts the validation that ensures it's not null. If year_inscribed is required and validated as non-null, the fallback to 0 is unnecessary and could mask validation issues.

Suggested change
year_inscribed: (int)($request['year_inscribed'] ?? 0),
year_inscribed: (int)$request['year_inscribed'],

Copilot uses AI. Check for mistakes.

namespace App\Packages\Features\QueryUseCases\ListQuery;

class WorldHeritageListQuery
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

There is an extra space between class and WorldHeritageListQuery. It should be class WorldHeritageListQuery.

Suggested change
class WorldHeritageListQuery
class WorldHeritageListQuery

Copilot uses AI. Check for mistakes.
return $this->unesco_site_url;
}

public function toArray(): array
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The toArray() method includes the category field but it's missing from the array structure (line 131). This inconsistency could lead to missing data when converting the object to array format.

Copilot uses AI. Check for mistakes.

private function refresh(): void
{
if (env('APP_ENV') === 'testing') {
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

Using env() directly in application code is not recommended. Consider using config() or App::environment() instead for better performance and consistency.

Suggested change
if (env('APP_ENV') === 'testing') {
if (config('app.env') === 'testing') {

Copilot uses AI. Check for mistakes.
@zigzagdev zigzagdev removed a link to an issue Aug 15, 2025
@zigzagdev zigzagdev linked an issue Aug 15, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create WorldHeritage Application Layer

2 participants