Skip to content

Commit

Permalink
Exchange: remove dependency on NumberFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
h4kuna committed Jan 12, 2023
1 parent cba295b commit daec714
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 238 deletions.
36 changes: 1 addition & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,46 +46,12 @@ echo $exchange->change(100, 'usd', 'czk'); // USD -> CZK = 2000.0

### Change driver and date

Download history exchange rates.
Download history exchange rates. Make new instance of Exchange with history rate.

```php
$exchange = $exchangeFactory->create(new \Datetime('2000-12-30'));
```

### Format output

Define output formats, for more information read this documentation [h4kuna/number-format](//github.com/h4kuna/number-format#numberformatstate).

```php
$formats = new Exchange\Currency\Formats(new \h4kuna\Number\NumberFormatFactory());

$formats->addFormat('EUR', ['decimalPoint' => '.', 'unit' => '€']);
```

Create [Filters](src/Filters.php) for format API.

```php
$filters = new Exchange\Filters($exchange, $formats, new h4kuna\Number\Tax(21));
```

Output

```php

// format 100 EUR like default to USD is set above
$filters->format(100); // '125,00 USD'

// count with VAT
$filters->formatVat(100, 'usd', 'eur'); // '96.80 €'
$filters->formatVatTo(100); // '151,25 USD'
$filters->formatTo(100, 'CZK'); // '2 000,00 CZK'

// Other options
$filters->change(100, 'usd', 'eur'); // 80.0
$filters->changeTo(100, 'usd'); // 125.0
$filters->vat(100); // 121.0
```

### Access and iterator

```php
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v7.1

- remove dependency on h4kuna/number-format
- Formats.php and Filters.php moved [this extension](//github.com/h4kuna/exchange-nette)

## v7.0

- your temporary rate implement by own RatingList
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"require": {
"php": ">=8.0",
"arvenil/ninja-mutex": "^0.6",
"h4kuna/number-format": "^3.0",
"h4kuna/serialize-polyfill": "^0.2",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^3.0"
Expand Down
82 changes: 0 additions & 82 deletions src/Currency/Formats.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public function transfer(float $price, ?string $from = null, ?string $to = null)
}

$from = $this->ratingList->get()->offsetGet($from ?? $this->configuration->from);

if ($to !== $from) {
$price *= $from->rate / $to->rate;
}
Expand Down
65 changes: 0 additions & 65 deletions src/Filters.php

This file was deleted.

26 changes: 0 additions & 26 deletions tests/src/Currency/FormatsTest.php

This file was deleted.

28 changes: 0 additions & 28 deletions tests/src/FiltersTest.php

This file was deleted.

0 comments on commit daec714

Please sign in to comment.