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

[Feature] Use client inteface or Psr Client interface #21

Open
aedart opened this issue Sep 16, 2022 · 2 comments
Open

[Feature] Use client inteface or Psr Client interface #21

aedart opened this issue Sep 16, 2022 · 2 comments

Comments

@aedart
Copy link

aedart commented Sep 16, 2022

Hi

In your \maxh\Nominatim\Nominatim constructor, you accept a custom Guzzle Client instance, which is really fine. But would it perhaps not be prudent to accept \GuzzleHttp\ClientInterface or \Psr\Http\Client\ClientInterface as argument?
If so, the your component's flexibility will increase, by allowing developers to provide custom http client implementations.

This feature request can be considered somewhat breaking. So, if you accept it, then it should be for your next major version.

@maxhelias
Copy link
Owner

Hi @aedart,

Indeed, this could be great.
We can event avoid breaking something by blocking Guzzle versions below 7.0 since \Guzzlient\Client implement \Psr\Http\Client\ClientInterface.

It's been a while since I worked on this project, here is some other idea that could be done :

  • Remove this statement :
    } elseif ($http_client instanceof Client) {
    $application_url_client = (string) $http_client->getConfig('base_uri');
    if (empty($application_url_client)) {
    throw new NominatimException('http_client must have a configured base_uri.');
    }
    if ($application_url_client !== $application_url) {
    throw new NominatimException('http_client parameter hasn\'t the same url application.');
    }
    } else {
    throw new NominatimException('http_client parameter must be a \\GuzzleHttp\\Client object or empty');
    }
  • Rework the $application_url param on the \maxh\Nominatim\Nominatim class because the base_uri is enough

@aedart
Copy link
Author

aedart commented Sep 18, 2022

Hi @maxhelias

That would be great.

As for you additional idea to remove $application_url juggling; I think you are right, it could simplify the constructor logic. However, that will become a breaking change, if your code adheres to semver 2. (You can always release a new major version - its all good for me).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants