Tools: tax rates, VAT id validation and more.

Maintainers

Package info

github.com/bambamboole/tools

pkg:composer/bambamboole/tools

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-08-08 12:55 UTC

This package is auto-updated.

Last update: 2026-08-08 12:57:39 UTC


README

A small toolbox for European commerce plumbing:

All amounts and rates are Brick\Math\BigDecimal — no floats.

Requirements

  • PHP 8.4+ with ext-soap and ext-dom

Installation

composer require bambamboole/tools

Usage

use Bambamboole\Tools\ToolManager;

$tools = new ToolManager();

// VAT rates for a country (TEDB)
$rates = $tools->taxRates()->getTaxRates('DE');

// Validate a VAT id (VIES)
$result = $tools->vatId()->validate('DE123456789');
$result->valid; // bool

// ECB euro reference rates, latest or historical
$day = $tools->exchangeRates()->getExchangeRates();
$day->rate('USD'); // BigDecimal

$day = $tools->exchangeRates()->getExchangeRates(new DateTimeImmutable('2020-03-13'));

// Convert money, incl. cross rates via EUR
use Brick\Math\RoundingMode;
use Brick\Money\Money;

$converter = $tools->currencyConverter();
$converter->convert(Money::of(100, 'USD'), 'GBP', roundingMode: RoundingMode::HalfEven);

Caching

The tax rate and exchange rate clients accept any Illuminate\Contracts\Cache\Repository (usable standalone, no Laravel app required). Fetched feeds are cached in bulk, historical days indefinitely, today's rates for 15 minutes. When the cache store supports atomic locks (Redis, Valkey, memcached, database), concurrent misses are collapsed into a single fetch.

use Illuminate\Cache\ArrayStore;
use Illuminate\Cache\Repository;

$cache = new Repository(new ArrayStore());
$rates = $tools->exchangeRates($cache)->getExchangeRates();

Laravel

The service provider is auto-discovered and wires everything against your default cache store — inject and go:

public function __construct(
    private readonly Bambamboole\Tools\ExchangeRates\ExchangeRatesClient $exchangeRates,
    private readonly Brick\Money\CurrencyConverter $converter,
) {}

Or use the auto-discovered Tools facade:

use Tools;

Tools::taxRates()->getTaxRates('DE');
Tools::vatId()->validate('DE123456789');
Tools::exchangeRates()->getExchangeRates();
Tools::currencyConverter()->convert(...);

Testing

composer test

License

MIT