PHP code example of webhub / vat

1. Go to this page and download the library: Download webhub/vat library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webhub / vat example snippets


use Webhub\Vat\Rates;

$rate = (new Rates)->in('NL')->current()->get();

$rate->rate(); // 0.21
$rate->currencyCode(); // 'EUR'

$rate = (new Rates)->in('BE')->at('1990-01-01')->get();
$rate->rate(); // 0.12

// with ->get()
(new Rates)->in('DE')->current()->get()->rate();
// equals shorter:
(new Rates)->in('DE')->current()->rate();

// non unique
(new Rates)->in('FR')->rate();  // throws AmbiguousResultException
(new Rates)->in('XX')->get();   // throws NoResultException

collect((new Rates)->in('NL')->all())
  ->sortBy('start_date')
  ->pluck('rate', 'start_date');