Skip to content

Commit

Permalink
Merge pull request #29 from mortola/feature/update-swap
Browse files Browse the repository at this point in the history
Upgrade to Swap 4.0
  • Loading branch information
florianv authored Jul 29, 2019
2 parents 23316f1 + 287bd89 commit 88c9c61
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
1 change: 0 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function getConfigTreeBuilder()
->end()
->end()
->end()
->append($this->createSimpleProviderNode('google'))
->append($this->createSimpleProviderNode('cryptonator'))
->append($this->createSimpleProviderNode('webservicex'))
->append($this->createSimpleProviderNode('central_bank_of_czech_republic'))
Expand Down
8 changes: 4 additions & 4 deletions DependencyInjection/FlorianvSwapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Florianv\SwapBundle\DependencyInjection;

use Psr\Cache\CacheItemPoolInterface;
use Psr\SimpleCache\CacheInterface;
use Swap;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand Down Expand Up @@ -107,8 +107,8 @@ public function configureCacheService(ContainerBuilder $container, array $config
$container->setDefinition($id, $definition);
} elseif ($container->hasDefinition($type)) {
$definition = $container->getDefinition($type);
if (!is_subclass_of($definition->getClass(), CacheItemPoolInterface::class)) {
throw new InvalidArgumentException("Service '$type' does not implements " . CacheItemPoolInterface::class);
if (!is_subclass_of($definition->getClass(), CacheInterface::class)) {
throw new InvalidArgumentException("Service '$type' does not implements " . CacheInterface::class);
}

$id = $type;
Expand All @@ -119,7 +119,7 @@ public function configureCacheService(ContainerBuilder $container, array $config
$definition = $container->getDefinition('florianv_swap.builder');
$definition
->replaceArgument(0, ['cache_ttl' => $ttl])
->addMethodCall('useCacheItemPool', [new Reference($id)]);
->addMethodCall('useSimpleCache', [new Reference($id)]);
}

/**
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Here is the list of the currently implemented services:
| [Central Bank of Russia](https://cbr.ru) | * | RUB | Yes |
| [WebserviceX](http://www.webservicex.net) | * | * | No |
| [1Forge](https://1forge.com) | * (free but limited or paid) | * (free but limited or paid) | No |
| [Google](https://www.google.com/finance) | * | * | No |
| [Cryptonator](https://www.cryptonator.com) | * Crypto (Limited standard currencies) | * Crypto (Limited standard currencies) | No |
| [CurrencyDataFeed](https://currencydatafeed.com) | * (free but limited or paid) | * (free but limited or paid) | No |
| [Open Exchange Rates](https://openexchangerates.org) | USD (free), * (paid) | * | Yes |
Expand Down
1 change: 0 additions & 1 deletion Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ florianv_swap:
currency_layer: # currencylayer
access_key: secret
enterprise: true
google: ~ # Google Finance
webservicex: ~ # WebserviceX
cryptonator: ~ # Cryptonator
forge: # Forge
Expand Down
2 changes: 0 additions & 2 deletions Tests/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public function provideValidProvidersConfigs()
[['central_bank_of_republic_turkey' => []]],
[['european_central_bank' => null]],
[['fixer' => ['access_key' => 'YOUR_KEY']]],
[['google' => null]],
[['national_bank_of_romania' => null]],
[['webservicex' => null]],
[['russian_central_bank' => null]],
Expand Down Expand Up @@ -161,7 +160,6 @@ public function provideInvalidProvidersConfigs()
[['central_bank_of_republic_turkey' => ['any' => 'any']]],
[['european_central_bank' => ['any' => 'any']]],
[['fixer' => ['any' => 'any']]],
[['google' => ['any']]],
[['national_bank_of_romania' => ['any' => 'any']]],
[['webservicex' => ['any' => 'any']]],
[['russian_central_bank' => ['any' => 'any']]],
Expand Down
8 changes: 4 additions & 4 deletions Tests/DependencyInjection/FlorianvSwapExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testProviderPriorities()
{
$this->buildContainer([
'fixer' => ['access_key' => 'YOUR_KEY'],
'google' => [
'european_central_bank' => [
'priority' => 3,
],
'forge' => [
Expand All @@ -91,9 +91,9 @@ public function testProviderPriorities()
$swap = $this->container->getDefinition('florianv_swap.builder');
$calls = $swap->getMethodCalls();

// Google first
// European Central Bank first
$this->assertEquals($calls[0][0], 'add');
$this->assertEquals($calls[0][1][0], 'google');
$this->assertEquals($calls[0][1][0], 'european_central_bank');
$this->assertEquals($calls[0][1][1], []);

// Forge second
Expand Down Expand Up @@ -165,7 +165,7 @@ private function assertCache($class, $config)
{
$swap = $this->container->getDefinition('florianv_swap.builder');
$calls = $swap->getMethodCalls();
$this->assertEquals($calls[0][0], 'useCacheItemPool');
$this->assertEquals($calls[0][0], 'useSimpleCache');
/** @var Reference $cacheReference */
$cacheReference = $calls[0][1][0];
$this->assertEquals('florianv_swap.cache', (string)$cacheReference);
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
"require": {
"php": "^5.6|^7.0",
"symfony/framework-bundle": "~3.0 || ~4.0",
"florianv/swap": "^3.4"
"florianv/swap": "^4.0"
},
"require-dev": {
"php-http/guzzle6-adapter": "^1.0",
"php-http/message": "^1.0",
"php-http/message": "^1.7",
"symfony/cache": "~3.0|~4.0",
"phpunit/phpunit": "~5.0"
"phpunit/phpunit": "~5.0",
"nyholm/psr7": "^1.1"
},
"suggest": {
"symfony/cache": "For caching"
Expand Down

0 comments on commit 88c9c61

Please sign in to comment.