Skip to content

Conversation

@JosephGabito
Copy link
Contributor

@JosephGabito JosephGabito commented Aug 5, 2025

Summary

Adds a new isType(string $type): bool method to the File DTO class, enabling specific MIME type checking beyond the existing predefined type methods.

Changes

  • New Method: File::isType(string $type): bool - delegates to MimeType object for flexible type checking
  • Code Quality: Improved comments and formatting for data URI pattern handling
  • Testing: Extended testMimeTypeMethods() to include assertions for the new isType() method

Testing

  • Added test cases for positive and negative type detection
  • Follows existing test patterns in testMimeTypeMethods()

Introduces the isType(string $type): bool method to the File DTO, allowing checks for specific MIME types. Also improves comments and formatting around data URI handling.
Extended the FileTest unit test to include assertions for the isType method, specifically verifying correct type detection for 'video', 'image', 'audio', and 'text'.
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@JosephGabito Thank you for the PR! I like that idea, only one point of feedback to clarify the purpose.

Refactored the File DTO method isType to isMimeType for clarity. Updated all relevant unit tests to use the new method name.
@JosephGabito JosephGabito requested a review from felixarntz August 5, 2025 20:27
Updated the docblock for the type parameter in the File DTO to specify that it expects a mime type (e.g. 'image', 'text', 'video', 'audio'). This improves code documentation and developer understanding.
@JosephGabito
Copy link
Contributor Author

@felixarntz Updated the method name to isMimeType() and adjusted the docblock + test assertions accordingly. Let me know if there's anything else you'd like me to tweak. Thanks 🙌

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@JosephGabito Thank you, looks great!

@felixarntz felixarntz merged commit 84c36cd into WordPress:trunk Aug 5, 2025
4 checks passed
@felixarntz felixarntz added this to the Finish the foundation milestone Aug 13, 2025
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.

2 participants