hydephp / develop

The HydePHP Source Code Monorepo
https://hydephp.com
MIT License
13 stars 6 forks source link

Add helper to get the File path extension #556

Closed caendesilva closed 2 years ago

caendesilva commented 2 years ago

This is a great task for Hacktoberfest beginners! (Some knowledge using PHPUnit may be required)

In the File class we have a few helpers that allows developers to write more fluent code, for example $file->getPath() to get the path. I propose we add a new helper, $path->getExtension() which uses pathinfo($file->path, PATHINFO_EXTENSION) to return the extension.

Here are some ideas for how I would go about implementing this, in case you need some ideas.

  1. Add a public function to File.php named getExtension() that uses the pathinfo() function to return the extension
  2. Add tests in the FileTest.php file, and verify the tests pass
  3. Submit a pull request with your changes to this (hydephp/develop) repository

If you're interested in giving this a shot, leave a comment so others know you are working on it. And let me know if you need any help! Good luck!

chikaldirick commented 2 years ago

Hey! I've just posted a PR that brings File::getExtension(): string method: https://github.com/hydephp/develop/pull/559 I've attached a simple test that check its functionality. Please, let me know if you need some adjustments there.

caendesilva commented 2 years ago

Hey! I've just posted a PR that brings File::getExtension(): string method: #559 I've attached a simple test that check its functionality. Please, let me know if you need some adjustments there.

Merged into master! Thank you for your contribution!