@@ -75,7 +75,7 @@ To get the name of a single currency, use the `name()` method:
7575
7676``` php
7777// 'United States Dollar'
78- $symbols = Otherguy\Currency\Symbol::name( Otherguy\Currency\Symbol::USD );
78+ $symbols = Otherguy\Currency\Symbol::name(Otherguy\Currency\Symbol::USD);
7979```
8080
8181### Initialize API Instance
@@ -162,10 +162,56 @@ $currency->convert(122.50, 'NPR', 'EUR', '2019-01-01'); // Convert 122.50 NPR to
162162```
163163
164164### Fluent Interface
165- ` TODO `
165+ Most methods can be used with a _ fluent interface_ , allowing you to chain method calls for more readable code:
166+
167+ ``` php
168+ // Namespaces are omitted for readability!
169+ DriverFactory::make('driver')->from(Symbol::USD)->to(Symbol::EUR)->get();
170+ DriverFactory::make('driver')->from(Symbol::USD)->to(Symbol::NPR)->date('2013-03-02')->historical();
171+ DriverFactory::make('driver')->from(Symbol::USD)->to(Symbol::NPR)->amount(12.10)->convert();
172+ ```
166173
167174### Conversion Result
168- ` TODO `
175+ The [ ` get() ` ] ( #latest-rates ) and [ ` historical() ` ] ( #historical-rates ) endpoints return a
176+ [ ` ConversionResult ` ] ( src/Results/ConversionResult.php ) object. This object allows you to perform calculations and
177+ conversions easily.
178+
179+ > !** Note:** Even though free accounts of most providers do not allow you to change the base currency, you can still
180+ > use the ` ConversionResult ` object to change the base currency later. This might not be as accurate as changing the
181+ > base currency directly, though.
182+
183+ > !** Note:** To convert between two currencies, you need to request both of them in your initial [ ` get() ` ] ( #latest-rates )
184+ > or [ ` historical() ` ] ( #historical-rates ) request. You can not convert between currencies that have not been fetched!
185+
186+ See the following code for some examples of what you can do with the ` ConversionResult ` object.
187+
188+ ``` php
189+ $result = DriverFactory::make('driver')->from(Symbol::USD)->to([Symbol::EUR, Symbol::GBP])->get();
190+
191+ // [ 'USD' => 1.00, 'EUR' => 0.89, 'GBP' => 0.79 ]
192+ $result->all();
193+
194+ // 'USD'
195+ $result->getBaseCurrency();
196+
197+ // '2019-06-11'
198+ $result->getDate();
199+
200+ // 0.89
201+ $result->rate(Symbol::EUR);
202+
203+ // CurrencyException("No conversion result for BTC!");
204+ $result->rate(Symbol::BTC);
205+
206+ // 5.618
207+ $result->convert(5.0, Symbol::EUR, Symbol::USD);
208+
209+ // [ 'USD' => 1.13, 'EUR' => 1.00, 'GBP' => 0.89 ]
210+ $result->setBaseCurrency(Symbol::EUR)->all();
211+
212+ // 1.12
213+ $result->setBaseCurrency(Symbol::GBP)->rate(Symbol::EUR);
214+ ```
169215
170216## Contributing 🚧
171217[ Pull Requests] ( https://github.com/otherguy/php-currency-api/pulls ) are more than welcome! I'm striving for 100% test
0 commit comments