PHP code example of malek83 / polish-vat-payer

1. Go to this page and download the library: Download malek83/polish-vat-payer 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/ */

    

malek83 / polish-vat-payer example snippets


use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()->build();

$bool = $validator->isValid('1568255600'); //returns boolean

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()->build();

/** @var \Malek83\PolishVatPayer\Result\PolishVatNumberVerificationResult $result */
$result = $validator->validate('1234567890');

var_dump($result->isValid()); // gives boolean, true if company is VAT Payer, otherwise false
var_dump($result->getVatNumber()); //gives string, the verificated VAT number
var_dump($result->getMessage()); //gives string, the human readable message

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()
    ->setCache(new AnyPsr16CompatibleCache())
    ->setTtl(new DateInterval('PT1H'))
    ->build();

use Malek83\PolishVatPayer\Builder\PolishVatPayerBuilder;
use Malek83\PolishVatPayer\PolishVatPayer;

/** @var PolishVatPayer $validator */
$validator = PolishVatPayerBuilder::builder()
    ->setLogger(new AnyPsr3CompatibleLogger())
    ->build();