Add isType() fallback method to MimeType value object#34
Merged
JasonTheAdams merged 4 commits intoWordPress:trunkfrom Aug 4, 2025
Merged
Add isType() fallback method to MimeType value object#34JasonTheAdams merged 4 commits intoWordPress:trunkfrom
JasonTheAdams merged 4 commits intoWordPress:trunkfrom
Conversation
Introduces a hasMimeType method to check if a MIME type starts with a given type, refactors isImage, isAudio, isVideo, and isText to use this new method, and adds corresponding unit tests.
JasonTheAdams
requested changes
Aug 4, 2025
Member
JasonTheAdams
left a comment
There was a problem hiding this comment.
Thanks, @JosephGabito! Added a suggestion.
Refactored the MimeType value object by renaming the hasMimeType method to isType for improved clarity. Updated all internal usages and corresponding unit tests to use the new method name.
Updated the isType method in MimeType to perform case-insensitive checks by converting the input to lowercase. Adjusted and expanded unit tests to verify case insensitivity and improved test coverage.
Updated the PHPDoc for the isType method to clarify that it checks if the stored MIME type begins with the given prefix, improving documentation accuracy and developer understanding.
JasonTheAdams
approved these changes
Aug 4, 2025
Member
JasonTheAdams
left a comment
There was a problem hiding this comment.
This is great! Nice improvement! Thank you!
Contributor
Author
|
Appreciate the fast review and the pointer on naming. Glad this helps tighten things up. 💪 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed
WordPress\AiClient\Files\ValueObjects\MimeType.isImage(),isAudio(),isVideo(), andisText()now delegate to isType() instead of repeating strpos() logic.testIsType()to cover positive and negative cases; all existing tests remain green.Why it matters
Open to feedback, happy to adjust if we'd like any tweaks