Skip to content

Commit

Permalink
Merge pull request #1 from rocketfellows/CVFV-45
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanim committed May 4, 2023
2 parents bd35947 + e7270ec commit edebe3c
Show file tree
Hide file tree
Showing 7 changed files with 2,522 additions and 40 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
8 changes: 4 additions & 4 deletions badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions clover.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1648587867">
<project timestamp="1648587867">
<metrics files="0" loc="0" ncloc="0" classes="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
<coverage generated="1683232917">
<project timestamp="1683232917">
<file name="/app/src/HRVatNumberFormatValidatorsConfig.php">
<class name="rocketfellows\HRVatNumberFormatValidatorsConfig\HRVatNumberFormatValidatorsConfig" namespace="global">
<metrics complexity="2" methods="2" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="2" elements="4" coveredelements="4"/>
</class>
<line num="13" type="method" name="getCountry" visibility="public" complexity="1" crap="1" count="8"/>
<line num="15" type="stmt" count="8"/>
<line num="18" type="method" name="getDefaultValidator" visibility="protected" complexity="1" crap="1" count="4"/>
<line num="20" type="stmt" count="4"/>
<metrics loc="23" ncloc="23" classes="1" methods="2" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="2" elements="4" coveredelements="4"/>
</file>
<metrics files="1" loc="23" ncloc="23" classes="1" methods="2" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="2" coveredstatements="2" elements="4" coveredelements="4"/>
</project>
</coverage>
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
// TODO: set name
"name": "rocketfellows/<country>-vat-number-format-validators-config",
"name": "rocketfellows/hr-vat-number-format-validators-config",
"authors": [
{
"name": "Arslan Imamutdinov",
Expand All @@ -11,8 +10,7 @@
"require": {
"php": ">=7.4",
"rocketfellows/specific-country-vat-number-format-validators-config": "1.0.0",
// TODO: require vat format validator package
"rocketfellows/<country>-vat-format-validator": "1.0.0"
"rocketfellows/hr-vat-format-validator": "1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
Expand All @@ -22,14 +20,12 @@
},
"autoload": {
"psr-4": {
// TODO: set namespace
"rocketfellows\\<country>VatNumberFormatValidatorsConfig\\": "src/"
"rocketfellows\\HRVatNumberFormatValidatorsConfig\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
// TODO: set namespace
"rocketfellows\\<country>VatNumberFormatValidatorsConfig\\tests\\": "tests/"
"rocketfellows\\HRVatNumberFormatValidatorsConfig\\tests\\": "tests/"
}
}
}
Loading

0 comments on commit edebe3c

Please sign in to comment.