Skip to content

(feat): add commentdata#57

Merged
ictbeheer merged 8 commits into
mainfrom
feat/comment
May 1, 2026
Merged

(feat): add commentdata#57
ictbeheer merged 8 commits into
mainfrom
feat/comment

Conversation

@ictbeheer
Copy link
Copy Markdown
Member

@ictbeheer ictbeheer commented Aug 7, 2025

Introduce the CommentData class to encapsulate comment details and enhance the post functionality by adding methods for comment count and retrieving comments.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 7, 2025

Coverage report for commit: 100b92b
File: coverage.xml

Cover ┌─────────────────────────┐ Freq.
   0% │ ███████████████████████ │ 75.0%
  10% │ ██░░░░░░░░░░░░░░░░░░░░░ │  6.3%
  20% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  30% │ ██░░░░░░░░░░░░░░░░░░░░░ │  6.3%
  40% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  50% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  60% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  70% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  80% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
  90% │ ░░░░░░░░░░░░░░░░░░░░░░░ │  0.0%
 100% │ ████░░░░░░░░░░░░░░░░░░░ │ 12.5%
      └─────────────────────────┘
 *Legend:* █ = Current Distribution 
Summary - Lines: 9.89% | Methods: 7.27%
FilesLinesMethodsBranches
src/Attributes
   Meta.php--100.00%
   MetaPrefix.php--100.00%
   TaxonomyPrefix.php--100.00%
   Terms.php--100.00%
src
   CommentData.php--100.00%
   ImageData.php--100.00%
   PostData.php8.94%7.41%100.00%
   TermData.php--100.00%
   UserData.php--100.00%
src/Contracts
   PostDataInterface.php100.00%100.00%100.00%
src/Enums
   PostStatus.php--100.00%
src/Mappers
   PostPrefixMapper.php--100.00%
   UserPrefixMapper.php--100.00%
src/Normalizers
   WPPostNormalizer.php--100.00%
src/Providers
   DataServiceProvider.php100.00%100.00%100.00%
src/Traits
   HasMeta.php25.00%-100.00%

🤖 comment via lucassabreu/comment-coverage-clover

@ictbeheer ictbeheer force-pushed the feat/comment branch 2 times, most recently from d1e8b5a to 7da491d Compare September 1, 2025 13:12
@ictbeheer ictbeheer marked this pull request as ready for review February 3, 2026 14:55
@ictbeheer ictbeheer requested a review from a team as a code owner February 3, 2026 14:55
Copy link
Copy Markdown
Contributor

@YvetteNikolov YvetteNikolov left a comment

Choose a reason for hiding this comment

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

Nice! Mooie toevoeging.

Vergeet de README niet te updaten.

Copilot AI review requested due to automatic review settings April 2, 2026 08:54
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

Adds first-class comment support to the data layer by introducing a CommentData DTO and extending PostData with helpers to fetch a post’s comment count and approved comments.

Changes:

  • Added PostData::commentCount() to expose the WordPress comment count for a post.
  • Added PostData::comments() to retrieve approved comments for a post.
  • Introduced CommentData with a fromComment(WP_Comment) constructor-style factory.

Reviewed changes

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

File Description
src/PostData.php Adds comment count and comment retrieval helpers on PostData.
src/CommentData.php Introduces CommentData and a fromComment() factory to map WP_Comment into a data object.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/PostData.php Outdated
Comment thread src/CommentData.php Outdated
Comment thread src/CommentData.php
Comment thread src/CommentData.php
Comment thread src/PostData.php Outdated
Comment on lines +315 to +333
public function commentCount(): ?int
{
if (null === $this->id || ! post_type_supports($this->postType, 'comments')) {
return null;
}

return (int) get_comments_number($this->id);
}

/**
* @param array<string, mixed> $args
*
* @return Collection<int, CommentData>
*/
public function comments(array $args = []): Collection
{
if (null === $this->id || ! post_type_supports($this->postType, 'comments')) {
return collect();
}
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

New behavior was added for comment counting and comment retrieval, but there are no tests covering these methods. Since PostData already has Pest/WP_Mock coverage, please add tests for commentCount() (supported vs unsupported post types and null ID) and comments() (default args and empty return when unsupported/null ID).

Copilot uses AI. Check for mistakes.
Comment thread src/PostData.php Outdated
postType: $post->post_type,
slug: $post->post_name,
thumbnail: get_post_thumbnail_id($post->ID) ? new ImageData(get_post_thumbnail_id($post->ID)) : null,
commentCount: (int) $post->comment_count,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is 'comment_count' er altijd? Zag dat je eerder nog een check deed of het post type comments ondersteunde?

post_type_supports($this->postType, 'comments')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ja, comment_count is een kolom in de wp_posts tabel. Maar misschien is het wel mooier om null te returnen voor post types die geen comments ondersteunen ipv 0

ictbeheer and others added 3 commits April 13, 2026 17:28
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@ictbeheer ictbeheer merged commit 135e828 into main May 1, 2026
6 checks passed
@ictbeheer ictbeheer deleted the feat/comment branch May 1, 2026 09:52
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.

5 participants