Skip to content

Conversation

zigzagdev
Copy link
Owner

Description

Implemented PostEntityCollection class as a dedicated collection wrapper for PostEntity objects.
It includes:

  • Constructor accepting an array of PostEntity
  • Static factory method build() for creating from raw array data
  • toArray() method for converting to associative array format
  • getPosts() to retrieve raw entity objects
  • addPost() to append a new PostEntity

Notes

  • The build() method depends on PostEntity::build(array) which must exist.
  • PHPDoc annotations were added for clarity and IDE/static analysis compatibility.

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.

Self Review

  • Entity collection builds from raw array data safely
  • Properly typed output in toArray()
  • Additions to collection function correctly
  • PHPDoc describes each method clearly

@zigzagdev zigzagdev linked an issue Jun 9, 2025 that may be closed by this pull request
@zigzagdev zigzagdev self-assigned this Jun 9, 2025
@zigzagdev zigzagdev requested a review from Copilot June 9, 2025 23:16
@zigzagdev zigzagdev added enhancement New feature or request backend labels Jun 9, 2025
@zigzagdev zigzagdev merged commit 3630b25 into feature/show-post-index-domain Jun 9, 2025
@zigzagdev zigzagdev deleted the feature/show-post-index-domain-collection branch June 9, 2025 23:17
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

Introduces a dedicated PostEntityCollection to encapsulate arrays of PostEntity objects, providing factory, conversion, and mutation methods.

  • Added PostEntityCollection with constructor, build(), toArray(), getPosts(), and addPost()
  • Created basic tests to verify collection instantiation and entity properties

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/app/Post/Domain/Entity/PostEntityCollection.php Defines the collection wrapper with array conversion and factory
src/app/Post/Domain/DomainTest/PostEntityCollectionTest.php Tests for building the collection and validating entity contents
Files not reviewed (1)
  • .idea/workspace.xml: Language not supported
Comments suppressed due to low confidence (6)

src/app/Post/Domain/Entity/PostEntityCollection.php:17

  • The docblock '@param array<> $posts' is too generic. Specify the array shape, e.g. '@param array<array{id: int|null, userId: int, content: string, mediaPath: string|null, visibility: string}> $posts' for better static analysis and IDE support.
* @param array<> $posts

src/app/Post/Domain/Entity/PostEntityCollection.php:33

  • There are no unit tests covering the toArray() method. Add a test to verify the returned array structure and values match expectations.
public function toArray(): array

src/app/Post/Domain/DomainTest/PostEntityCollectionTest.php:48

  • [nitpick] Rename 'test_check_collection_type' to follow PHPUnit conventions and improve clarity, e.g. 'testBuildReturnsPostEntityCollectionInstance'.
public function test_check_collection_type(): void

src/app/Post/Domain/DomainTest/PostEntityCollectionTest.php:55

  • [nitpick] Rename 'test_check_collection_value' to something more descriptive like 'testBuildCreatesEntitiesWithCorrectValues'.
public function test_check_collection_value(): void

src/app/Post/Domain/DomainTest/PostEntityCollectionTest.php:28

  • [nitpick] Consider renaming 'arrayMultiData' to a clearer name such as 'providePostData' or using PHPUnit's @dataProvider pattern for improved readability.
public function arrayMultiData(): array

src/app/Post/Domain/DomainTest/PostEntityCollectionTest.php:1

  • [nitpick] The test file is located under src/; consider moving test classes to a dedicated tests/ directory to clearly separate production code from test code.
<?php

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.

Create Post Entity Collection

1 participant