Skip to content

Commit 6677eed

Browse files
committed
Update README.md for "Currencies Update"
1 parent e31c2d9 commit 6677eed

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,11 @@ In order to get a specific currency:
277277
use PostScripton\Money\Currency;
278278

279279
$usd = Currency::code('USD');
280+
$usd = Currency::code('usd');
281+
$usd = Currency::code('840');
280282
```
281283

282-
❗ Only international codes such as USD”, “EUR”, “RUB and so on should be used as a code.
284+
❗ Only international codes such as USD / 840, EUR / 978, RUB / 643 and so on should be used as a code.
283285

284286
---
285287

@@ -291,11 +293,29 @@ You can also get or change some data from Currency object:
291293
use PostScripton\Money\Currency;
292294

293295
$usd = Currency::code('USD');
294-
$usd->getCode(); // USD
296+
297+
$usd->getFullName(); // "United States dollar"
298+
$usd->getName(); // "dollar"
299+
$usd->getCode(); // "USD"
300+
$usd->getNumCode(); // "840"
295301
$usd->getSymbol(); // "$"
296302
$usd->getPosition(); // 0 (Currency::POS_START)
297303
```
298304

305+
`getSymbol()` takes an index as first parameter only if there are more than one symbol for the currency.
306+
307+
```php
308+
use PostScripton\Money\Currency;
309+
310+
Currency::setCurrencyList(Currency::LIST_ALL);
311+
312+
$currency = Currency::code('EGP');
313+
314+
// ['£', 'ج.م']
315+
$currency->getSymbol(); // '£'
316+
$currency->getSymbol(1); // 'ج.م'
317+
```
318+
299319
---
300320

301321
#### Position
@@ -319,6 +339,49 @@ $money->toString(); // "123.4 $"
319339

320340
---
321341

342+
#### Display
343+
You may specify the way to display the currency whether it will be as an iso-code or a symbol.
344+
Use following constants:
345+
346+
```php
347+
use PostScripton\Money\Currency;
348+
use PostScripton\Money\Money;
349+
350+
$money = new Money(1234);
351+
352+
$money->settings->getCurrency()->getDisplay(); // 10 (Currency::DISPLAY_SYMBOL)
353+
$money->toString(); // "$ 123.4"
354+
355+
$money->settings->getCurrency()->setDisplay(Currency::DISPLAY_CODE);
356+
357+
$money->settings->getCurrency()->getDisplay(); // 11 (Currency::DISPLAY_CODE)
358+
$money->toString(); // "USD 123.4"
359+
360+
// If you don't like the look of the code at the beginning
361+
$money->settings->getCurrency()->setPosition(Currency::POS_END);
362+
$money->toString(); // "123.4 USD"
363+
```
364+
365+
---
366+
367+
#### Currency List
368+
If you wish, you may select another currency list.
369+
To select currency list by default, go to the `config/money.php` and find there `currency_list`.
370+
371+
All the lists are located at `vendor/postscripton/money/src/List`, so if you want, you can check something up there.
372+
373+
```php
374+
use PostScripton\Money\Currency;
375+
376+
Currency::setCurrencyList(Currency::LIST_POPULAR);
377+
Currency::code('USD');
378+
379+
Currency::setCurrencyList(Currency::LIST_ALL);
380+
Currency::code('EGP');
381+
```
382+
383+
---
384+
322385
### 💵 Money
323386
Here we are, prepared and ready to create our own Money objects.
324387

0 commit comments

Comments
 (0)