<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rocketfellows / specific-country-vat-number-format-validators-config example snippets
class DEVatNumberFormatValidatorsConfig extends SpecificCountryVatNumberFormatValidatorsConfig
{
public function getCountry(): Country
{
return ISO3166::DE();
}
protected function getDefaultValidator(): CountryVatFormatValidatorInterface
{
return new DEVatFormatValidator();
}
}
$config = new DEVatNumberFormatValidatorsConfig();
// will return Country instance for Germany (according to standard ISO 3166)
$config->getCountry();
// will return CountryVatFormatValidators tuple with one item, which is DEVatFormatValidator instance
$config->getValidators();
class AnotherDEVatFormatValidator implements CountryVatFormatValidatorInterface
{
public function isValid(string $vatNumber): bool
{
// add some implementation
}
}
$config = new DEVatNumberFormatValidatorsConfig(new AnotherDEVatFormatValidator());
// will return Country instance for Germany (according to standard ISO 3166)
$config->getCountry();
// will return CountryVatFormatValidators tuple with one item, which is AnotherDEVatFormatValidator instance
$config->getValidators();
$config = new DEVatNumberFormatValidatorsConfig(
null,
(
new CountryVatFormatValidators(
new AnotherDEVatFormatValidator()
)
)
);
// will return Country instance for Germany (according to standard ISO 3166)
$config->getCountry();
// will return CountryVatFormatValidators tuple with two items:
// object instance of DEVatFormatValidator
// and object instance of AnotherDEVatFormatValidator
$config->getValidators();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.