Skip to content

Commit

Permalink
[CVFV-45] setup readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanim committed May 4, 2023
1 parent d8db90e commit 2b99a94
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# <Country> vat number format validators config
# Croatia vat number format validators config

![Code Coverage Badge](./badge.svg)

This package provides a preconfigured configuration class for vat number format validators for <Country> country.
This package provides a preconfigured configuration class for vat number format validators for Croatia country.
Is an extension of the package https://github.com/rocketfellows/specific-country-vat-number-format-validators-config.

## Installation

```shell
composer require rocketfellows/<country>-vat-number-format-validators-config
composer require rocketfellows/hr-vat-number-format-validators-config
```

## Dependencies

- https://github.com/rocketfellows/specific-country-vat-number-format-validators-config v1.0.0;
- https://github.com/rocketfellows/<country>-vat-format-validator v1.0.0;
- https://github.com/rocketfellows/hr-vat-format-validator v1.0.0;

## References

Expand All @@ -23,31 +23,31 @@ composer require rocketfellows/<country>-vat-number-format-validators-config

## List of package components

- **_rocketfellows\<country>VatNumberFormatValidatorsConfig\<country>VatNumberFormatValidatorsConfig_** - preconfigured configuration class for vat number format validators for <Country> country;
- **_rocketfellows\HRVatNumberFormatValidatorsConfig\HRVatNumberFormatValidatorsConfig_** - preconfigured configuration class for vat number format validators for Croatia country;

## <country>VatNumberFormatValidatorsConfig description
## HRVatNumberFormatValidatorsConfig description

A configuration class that provides a match for the vat number format validators for the country <country>.
A configuration class that provides a match for the vat number format validators for the country Croatia.

Class interface:
- **_getCountry_** - returns <country> **_Country_** instance;
- **_getCountry_** - returns Croatia **_Country_** instance;
- **_getValidators_** - returns validators tuple

When initializing the default configuration, the **_getValidators_** function returns a tuple with a single validator - an instance of <country>VatFormatValidator.
When initializing the default configuration, the **_getValidators_** function returns a tuple with a single validator - an instance of HRVatFormatValidator.

```php
$config = new <country>VatNumberFormatValidatorsConfig();
$config = new HRVatNumberFormatValidatorsConfig();

$config->getCountry(); // returns <country> Country instance
$config->getValidators(); // returns CountryVatFormatValidators with one item - instance of <country>VatFormatValidator
$config->getCountry(); // returns Croatia Country instance
$config->getValidators(); // returns CountryVatFormatValidators with one item - instance of HRVatFormatValidator
```

You can override the default validator by initializing the configuration class object with a new default validator through the first parameter of the class constructor.
Attention - validator must implement interface **_CountryVatFormatValidatorInterface_**.

```php
$newDefaultValidator = new NewDefaultValidator(); // instance of CountryVatFormatValidatorInterface
$config = new <country>VatNumberFormatValidatorsConfig($newDefaultValidator); // initialize with new default validator
$config = new HRVatNumberFormatValidatorsConfig($newDefaultValidator); // initialize with new default validator

$config->getValidators(); // returns CountryVatFormatValidators with one item - $newDefaultValidator
```
Expand All @@ -61,7 +61,7 @@ And each additional validator must implement interface **_CountryVatFormatValida
$firstAdditionalValidator = new FirstAdditionalValidator(); // instance of CountryVatFormatValidatorInterface
$secondAdditionalValidator = new SecondAdditionalValidator(); // instance of CountryVatFormatValidatorInterface

$config = new <country>VatNumberFormatValidatorsConfig(
$config = new HRVatNumberFormatValidatorsConfig(
null,
(
new CountryVatFormatValidators(
Expand All @@ -72,7 +72,7 @@ $config = new <country>VatNumberFormatValidatorsConfig(
);

// returns CountryVatFormatValidators with three items:
// default preconfigured validator by default - instance of <country>VatFormatValidator
// default preconfigured validator by default - instance of HRVatFormatValidator
// $firstAdditionalValidator - from additional tuple
// $secondAdditionalValidator - from additional tuple
$config->getValidators();
Expand All @@ -85,7 +85,7 @@ $defaultValidator = new DefaultValidator(); // instance of Cou
$firstAdditionalValidator = new FirstAdditionalValidator(); // instance of CountryVatFormatValidatorInterface
$secondAdditionalValidator = new SecondAdditionalValidator(); // instance of CountryVatFormatValidatorInterface

$config = new <country>VatNumberFormatValidatorsConfig(
$config = new HRVatNumberFormatValidatorsConfig(
$defaultValidator,
(
new CountryVatFormatValidators(
Expand Down

0 comments on commit 2b99a94

Please sign in to comment.