Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

This pull request introduces the following data transfer objects to represent post data returned from the GetAllUserPost use case:

  • GetAllUserPostDto: A readonly value object encapsulating an individual post's ID, user ID, content, optional media path, and visibility status.
  • GetAllUserPostDtoCollection: A typed collection of GetAllUserPostDto instances, designed to standardise the output of multiple post entities in a structured format.

Implementation Details

  • GetAllUserPostDto includes a static build() method to construct an instance from a flat array, and a toArray() method for serialisation purposes.
  • GetAllUserPostDtoCollection wraps an array of DTOs and provides a build() factory for consistency with DDD-style instantiation.

Copy link
Owner Author

@zigzagdev zigzagdev left a comment

Choose a reason for hiding this comment

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

  • Confirmed that all fields in GetAllUserPostDto are strictly typed and immutable (readonly).
  • Verified that build() methods in both DTO and Collection validate the input structure as expected.
  • Ensured compatibility with existing application layers by keeping userId and mediaPath naming consistent.
  • Unit tests comprehensively cover both normal and edge cases, including missing mediaPath.
  • Considered future extensibility by avoiding premature abstraction (no factory class for now — inline static method suffices).

@zigzagdev zigzagdev changed the base branch from main to feature/show-post-index June 14, 2025 07:38
@zigzagdev zigzagdev requested a review from Copilot June 14, 2025 07:38
@zigzagdev zigzagdev self-assigned this Jun 14, 2025
@zigzagdev zigzagdev added enhancement New feature or request backend labels Jun 14, 2025
@zigzagdev zigzagdev linked an issue Jun 14, 2025 that may be closed by this pull request
@zigzagdev zigzagdev changed the base branch from feature/show-post-index to feature/show-post-index-application June 14, 2025 07:39
Copy link

@Copilot 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 DTO classes for the GetAllUserPost use case, providing structured value objects and a collection wrapper.

  • Adds GetAllUserPostDto with build() for instantiation and toArray() for serialization.
  • Introduces GetAllUserPostDtoCollection with a build() factory and getPosts() accessor.
  • Provides unit tests validating DTO and collection construction and property values.

Reviewed Changes

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

File Description
src/app/Post/Application/Dto/GetAllUserPostDto.php Added DTO with constructor, build(), and toArray() methods
src/app/Post/Application/Dto/GetAllUserPostDtoCollection.php Added collection class with build() factory and getPosts() method
src/app/Post/Application/ApplicationTest/GetAllUserPostDtoTest.php Added tests for DTO instantiation and value assertions
src/app/Post/Application/ApplicationTest/GetAllUserPostDtoCollectionTest.php Added tests for collection instantiation and per-item value checks
Files not reviewed (1)
  • .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (6)

src/app/Post/Application/Dto/GetAllUserPostDtoCollection.php:16

  • Consider adding a PHPDoc block to build() to describe the expected structure of $items, for example @param array<string,mixed>[] $items to clarify that each element is raw post data.
public static function build(array $items): self

src/app/Post/Application/Dto/GetAllUserPostDto.php:26

  • There's no unit test covering toArray()—add a test to assert that toArray() output matches the DTO properties for full serialization coverage.
public function toArray(): array

src/app/Post/Application/ApplicationTest/GetAllUserPostDtoTest.php:10

  • [nitpick] The setUp() override is empty and not used—consider removing it to reduce boilerplate in tests.
protected function setUp(): void

src/app/Post/Application/ApplicationTest/GetAllUserPostDtoTest.php:15

  • [nitpick] The tearDown() override is empty—consider removing it if there's no custom teardown logic.
protected function tearDown(): void

src/app/Post/Application/ApplicationTest/GetAllUserPostDtoCollectionTest.php:10

  • [nitpick] This setUp() method is overridden but empty—removing it can streamline the test class.
protected function setUp(): void

src/app/Post/Application/ApplicationTest/GetAllUserPostDtoCollectionTest.php:15

  • [nitpick] This empty tearDown() override isn't used—consider removing it for cleaner test code.
protected function tearDown(): void

@zigzagdev zigzagdev merged commit e80f811 into feature/show-post-index-application Jun 14, 2025
@zigzagdev zigzagdev deleted the feautre/show-post-index-application-dto branch June 14, 2025 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Show Posts Index Dto (with Pagination)

1 participant