Skip to content
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 a new Filesystem::ensureParentDirectoryExists() method? #2072

Open
caendesilva opened this issue Dec 25, 2024 · 1 comment
Open

Add a new Filesystem::ensureParentDirectoryExists() method? #2072

caendesilva opened this issue Dec 25, 2024 · 1 comment

Comments

@caendesilva
Copy link
Member

Could reduce repetition when we call Filesystem::ensureDirectoryExists(dirname$path))

@caendesilva
Copy link
Member Author

It seems like a useful addition if it can simplify repetitive code and improve readability. If there are multiple instances where Filesystem::ensureDirectoryExists(dirname($path)) is being used, encapsulating it into Filesystem::ensureParentDirectoryExists() would make the intent clearer and reduce boilerplate.

This method would also be easier for developers to understand at a glance, as the name explicitly describes the purpose. However, it might not be necessary if this scenario is rare or if there’s no significant gain in terms of clarity or maintainability.

Before implementing, I’d consider:

  1. Usage Frequency: How often does this pattern occur across the codebase?
  2. Impact on Readability: Does this improve readability enough to justify adding another method to the Filesystem class?
  3. Backwards Compatibility: Could this potentially cause confusion for existing users of the API, or is it purely additive?

If the answers are favorable, it sounds like a small but worthwhile enhancement!

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

No branches or pull requests

1 participant