Skip to content

feat: return typed DTOs from files/checks/commits#11

Merged
jordanpartridge merged 1 commit intomasterfrom
feature/issue-5-typed-dtos
Dec 12, 2025
Merged

feat: return typed DTOs from files/checks/commits#11
jordanpartridge merged 1 commit intomasterfrom
feature/issue-5-typed-dtos

Conversation

@jordanpartridge
Copy link
Copy Markdown
Contributor

Summary

  • Created File DTO for file change information with helper methods (isAdded(), isModified(), isRemoved(), isRenamed())
  • Created Commit DTO for commit data including SHA, message, author/committer info
  • Created CommitAuthor DTO for git-level author/committer details (name, email, date)
  • Updated files() method to return File[] instead of raw arrays
  • Updated checks() method to return CheckRun[] instead of raw arrays
  • Updated commits() method to return Commit[] instead of raw arrays
  • Added comprehensive test coverage for all new DTOs
  • Updated existing tests to validate typed return values

All new DTOs follow the existing pattern with readonly properties, fromArray() factory methods, and toArray() serialization.

Test Plan

  • Created unit tests for File DTO
  • Created unit tests for CommitAuthor DTO
  • Created unit tests for Commit DTO
  • Updated PullRequestWrapperTest to test typed returns
  • All tests passing (36 tests, 154 assertions)
  • PHPStan analysis passing (level 8)
  • Code style passing (Laravel Pint)

Fixes #5

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 12, 2025

Warning

Rate limit exceeded

@jordanpartridge has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e8cb097 and e5c6336.

📒 Files selected for processing (8)
  • src/DataTransferObjects/Commit.php (1 hunks)
  • src/DataTransferObjects/CommitAuthor.php (1 hunks)
  • src/DataTransferObjects/File.php (1 hunks)
  • src/PullRequest.php (6 hunks)
  • tests/Unit/DataTransferObjects/CommitAuthorTest.php (1 hunks)
  • tests/Unit/DataTransferObjects/CommitTest.php (1 hunks)
  • tests/Unit/DataTransferObjects/FileTest.php (1 hunks)
  • tests/Unit/PullRequestWrapperTest.php (6 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/issue-5-typed-dtos

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This change enhances type safety by returning strongly-typed DTOs
instead of raw arrays from the files(), checks(), and commits() methods.

Changes:
- Created File DTO for file change information
- Created Commit DTO for commit data
- Created CommitAuthor DTO for git-level author/committer info
- Updated files() to return File[] instead of array
- Updated checks() to return CheckRun[] instead of array
- Updated commits() to return Commit[] instead of array
- Added comprehensive test coverage for all new DTOs
- Updated existing tests to validate typed return values

All DTOs follow the existing pattern with:
- Readonly properties
- fromArray() factory method
- toArray() serialization method
- Helper methods (isAdded(), isModified(), etc.)

Fixes #5
@jordanpartridge jordanpartridge force-pushed the feature/issue-5-typed-dtos branch from 29e9dba to e5c6336 Compare December 12, 2025 15:59
@jordanpartridge jordanpartridge merged commit d025c43 into master Dec 12, 2025
3 checks passed
@jordanpartridge jordanpartridge deleted the feature/issue-5-typed-dtos branch December 12, 2025 15:59
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.

Return typed DTOs from files(), checks(), commits()

1 participant