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

Fix issue #20 : add getAvailableCurrencies method for ProviderInterface #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

slavielle
Copy link
Contributor

No description provided.

*
* @return array
*/
public function getSupportedCurrencies();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about creating a different interface like ProvidesSupportedCurrencies for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello ojhaujjwal,

I would say it's a bit of over designing but you're the captain on board captain ;)

I'll do this shortly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well thinking about it, putting getSupportedCurrencies in another interface may cause an inconsistency back to the CurrencyConverter class ...

let's consider this :

    public function setCacheAdapter(Cache\Adapter\CacheAdapterInterface $cacheAdapter)
    {
        $this->setCachable(true);
        $this->cacheAdapter = $cacheAdapter;

        return $this;
    } 

if we check $cacheAdapter is Cache\Adapter\CacheAdapterInterface here, then we can't be sure getSupportedCurrencies is implemented in $cacheAdapter if declaration is not included in CacheAdapterInterface ... see ?

@ojhaujjwal
Copy link
Owner

we also need to check if the currencies are supported in the main class while calculating the exchange rate.

@slavielle
Copy link
Contributor Author

we also need to check if the currencies are supported in the main class while calculating the exchange rate.

are you talking about CurrencyConverter::convert method ?

@slavielle
Copy link
Contributor Author

Thinking about it, supported currencies also require caching ... I implemented it in the former commit.
I also implemented checking if the currencies are supported in the main class while calculating the exchange rate as you asked for.

What do you think about this last commit ?

@ojhaujjwal
Copy link
Owner

+1 man. I like the overall idea. I will weigh in my comments.

*/
public function getSupportedCurrencies()
{
$result = json_decode($this->httpClient->get(self::FIXER_API_BASEPATH)->getBody(), true);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get forbidden at times while accessing this endpoint.

/**
* {@inheritDoc}
*/
function supportedCurrenciesCacheExists()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't omit method visibility


interface ProvidesSupportedCurrenciesCacheInterface
{
const SUPPORTED_CURRENCIES_CACHE_KEY_NAME = 'supported-currencies';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary space

@ojhaujjwal
Copy link
Owner

Apologies for delays. I will write all my comments this weekend.

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