Skip to content

Commit c8c1df3

Browse files
committed
Added WebserviceX provider
1 parent 3553668 commit c8c1df3

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getConfigTreeBuilder()
4747
->scalarNode('token')->isRequired()->cannotBeEmpty()->end()
4848
->end()
4949
->end()
50-
->end()
50+
->scalarNode('webservicex')->end()
5151
->end()
5252
->end()
5353
->end()

DependencyInjection/FlorianvSwapExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function load(array $config, ContainerBuilder $container)
4141
case 'yahoo_finance':
4242
case 'google_finance':
4343
case 'european_central_bank':
44+
case 'webservicex':
4445
$this->addProvider($container, $providerName, array(
4546
new Reference('florianv_swap.client')
4647
));

Resources/config/services.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<parameter key="florianv_swap.provider.european_central_bank.class">Swap\Provider\EuropeanCentralBank</parameter>
1313
<parameter key="florianv_swap.provider.open_exchange_rates.class">Swap\Provider\OpenExchangeRates</parameter>
1414
<parameter key="florianv_swap.provider.xignite.class">Swap\Provider\Xignite</parameter>
15+
<parameter key="florianv_swap.provider.webservicex.class">Swap\Provider\WebserviceX</parameter>
1516
</parameters>
1617

1718
<services>

Resources/doc/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ florianv_swap:
9494
token: secret
9595
```
9696
97+
### WebserviceX
98+
99+
```yaml
100+
# app/config/config.yml
101+
florianv_swap:
102+
providers:
103+
webservicex: ~
104+
```
105+
97106
You can register multiple providers, they will be called in chain. In this example the Yahoo Finance is
98107
the first one and Google Finance is the second one:
99108

Tests/DependencyInjection/FlorianvSwapExtensionTest.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testSwapService()
4242

4343
public function testYahooFinanceProvider()
4444
{
45-
$config = $this->createProvidersConfig(array('yahoo_finance' => true));
45+
$config = $this->createProvidersConfig(array('yahoo_finance' => null));
4646
$this->extension->load($config, $this->container);
4747

4848
$definition = $this->container->getDefinition('florianv_swap.provider.yahoo_finance');
@@ -54,7 +54,7 @@ public function testYahooFinanceProvider()
5454

5555
public function testGoogleFinanceProvider()
5656
{
57-
$config = $this->createProvidersConfig(array('google_finance' => true));
57+
$config = $this->createProvidersConfig(array('google_finance' => null));
5858
$this->extension->load($config, $this->container);
5959

6060
$definition = $this->container->getDefinition('florianv_swap.provider.google_finance');
@@ -66,7 +66,7 @@ public function testGoogleFinanceProvider()
6666

6767
public function testEuropeanCentralBankProvider()
6868
{
69-
$config = $this->createProvidersConfig(array('european_central_bank' => true));
69+
$config = $this->createProvidersConfig(array('european_central_bank' => null));
7070
$this->extension->load($config, $this->container);
7171

7272
$definition = $this->container->getDefinition('florianv_swap.provider.european_central_bank');
@@ -111,6 +111,18 @@ public function testOpenExchangeRatesProvider()
111111
$this->assertEquals(array(new Reference('florianv_swap.client'), 'secret', true), $definition->getArguments());
112112
}
113113

114+
public function testWebserviceXProvider()
115+
{
116+
$config = $this->createProvidersConfig(array('webservicex' => null));
117+
$this->extension->load($config, $this->container);
118+
119+
$definition = $this->container->getDefinition('florianv_swap.provider.webservicex');
120+
121+
$this->assertFalse($definition->isPublic());
122+
$this->assertTrue($definition->hasTag('florianv_swap.provider'));
123+
$this->assertEquals(array(new Reference('florianv_swap.client')), $definition->getArguments());
124+
}
125+
114126
/**
115127
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
116128
*/
@@ -135,8 +147,8 @@ public function testXigniteProvider()
135147
public function testMultipleProviders()
136148
{
137149
$config = $this->createProvidersConfig(array(
138-
'yahoo_finance' => true,
139-
'google_finance' => true,
150+
'yahoo_finance' => null,
151+
'google_finance' => null,
140152
'xignite' => array('token' => 'secret')
141153
));
142154
$this->extension->load($config, $this->container);

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"name": "florianv/swap-bundle",
33
"type": "symfony-bundle",
44
"description": "Integrates the Swap library with Symfony2",
5-
"keywords": ["swap"],
5+
"keywords": ["money", "currency", "conversion", "rate", "exchange"],
66
"homepage": "https://github.com/florianv/FlorianvSwapBundle",
77
"license": "MIT",
88
"authors": [
99
{
1010
"name": "Florian Voutzinos",
1111
"email": "[email protected]",
12-
"homepage": "http://voutzinos.com"
12+
"homepage": "http://florian.voutzinos.com"
1313
}
1414
],
1515
"require": {

0 commit comments

Comments
 (0)