Closed ddinchev closed 7 years ago
Thank you for this issue.
I usually make all classes final as it is much easier to remove a final
than adding one. For this specific class there are no real reasons. You can send a PR to remove it if you want.
May I ask why you need to extend the ProviderAggregator
?
I don't - just not having an interface makes it a requirement to mock the class itself. And final classes are not mockable.
One potential case for extending (or providing an alternative implementation of such aggregator) is such where you would have a certain logic to automatically select a provider based on your query. For example -> use geoip2
for valid IP address geocode()
calls, use google maps
for anything else. Given the popularity of the library, I think more options to extend the library are better. I'd be happy with an interface covering the public API of the class as well 👍
That is an cool idea. Let me make a PR for that.
Thank you @ddinchev.
I will close this PR. ProviderAggregator
is not final any more and your specific use case is now supported in the library.
In my application, I have a thin wrapper around geocoder, that would depend on
Geocoder\ProviderAggregator
. I'd test that by mocking it. However, mocking final classes is not possible (not with the defacto standardphpunit-mock-objects
at least). So after updating to the latest master, my tests now break.What is the benefit or goal of having the
ProviderAggregator
to be final? Could we also extract an Aggregator interface?