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

chore: refactor services to eliminate code duplication #27

Merged
merged 3 commits into from
Sep 19, 2023
Merged

Conversation

imorland
Copy link
Member

@imorland imorland commented Sep 19, 2023

Overview:

This PR introduces several enhancements to fof/geoip. The primary change is the introduction of a base class for the GeoIP services, which refactors and streamlines the service implementations.

Additionally, a trait for handling GeoIP errors has been added, and localization updates have been made.

Key Changes:

  • Localization Update: The description for the IPData service in resources/locale/en.yml has been updated to mention the availability of paid plans for higher usage limits.
  • Refactoring GeoIP Service Classes: A new base class BaseGeoService has been introduced in Api/Services/BaseGeoService.php. This abstracts away common functionality from the individual service classes, providing a cleaner and more standardized approach.
    • The service classes for IPApi, IPData, IPLocation, and IPStack have been refactored to extend this new base class.
    • Common methods such as building the request URL, checking for errors, and handling errors have been abstracted into the base class.
  • Handling GeoIP Errors: A new trait HandlesGeoIPErrors has been added in Traits/HandlesGeoIPErrors.php. This trait provides a method to handle GeoIP errors and is used in the GeoIP class.
  • Miscellaneous Updates:
    • The constructor of the GeoIP class has been updated to use the shorthand syntax for property promotion.
    • The RetrieveIP class has been updated to use the contract for the cache repository instead of the concrete implementation..

@imorland imorland merged commit 46e64e6 into master Sep 19, 2023
4 checks passed
@imorland imorland deleted the im/refactor branch September 19, 2023 10:17
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