-
Couldn't load subscription status.
- Fork 34
Add isType() fallback method to MimeType value object #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isType() fallback method to MimeType value object #34
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Nice improvement! Thank you!
|
Appreciate the fast review and the pointer on naming. Glad this helps tighten things up. 💪 |
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