-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6c642db
Showing
23 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: CI-CHECKS | ||
|
||
on: [push] | ||
|
||
jobs: | ||
run-phpcs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: php-actions/composer@v6 | ||
- name: PHPCS analyze | ||
run: ./vendor/bin/phpcs -p -s --standard=phpcs.xml src tests | ||
run-php-stan: | ||
needs: run-phpcs | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: php-actions/composer@v6 | ||
- name: PHPStan Static Analysis source code | ||
uses: php-actions/phpstan@v3 | ||
with: | ||
version: 1.10.14 | ||
configuration: ./phpstan.neon.dist | ||
run-php-unit-tests: | ||
needs: run-php-stan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: php-actions/composer@v6 | ||
- uses: php-actions/phpunit@v3 | ||
with: | ||
version: 9.5.28 | ||
bootstrap: vendor/autoload.php | ||
configuration: phpunit.xml | ||
args: --coverage-text | ||
run-assemble-php-unit-coverage: | ||
needs: run-php-unit-tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: php-actions/composer@v6 | ||
- name: Run PHPUnit Tests | ||
uses: php-actions/phpunit@v3 | ||
with: | ||
version: 9.5.28 | ||
php_extensions: xdebug | ||
bootstrap: vendor/autoload.php | ||
configuration: phpunit.xml | ||
args: --coverage-text | ||
env: | ||
XDEBUG_MODE: coverage | ||
- name: Generate test coverage badge | ||
uses: timkrase/[email protected] | ||
with: | ||
report: ./clover.xml | ||
coverage_badge_path: 'badge.svg' | ||
push_badge: true | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
composer.phar | ||
/vendor/ | ||
.idea | ||
.phpunit.result.cache | ||
|
||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control | ||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file | ||
# composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM php:7.4-fpm | ||
RUN apt-get update && apt-get install -y \ | ||
zlib1g-dev \ | ||
libzip-dev \ | ||
unzip \ | ||
mc | ||
RUN docker-php-ext-install zip | ||
RUN pecl install xdebug-3.1.5 | ||
RUN docker-php-ext-enable xdebug | ||
RUN mkdir -p /home/app | ||
WORKDIR /home/app | ||
COPY . /home/app | ||
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# <Country> 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. | ||
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 | ||
``` | ||
|
||
## 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; | ||
|
||
## References | ||
|
||
- https://github.com/rocketfellows/country-vat-format-validator-interface | ||
- https://github.com/arslanim/iso-standard-3166 | ||
|
||
## List of package components | ||
|
||
- **_rocketfellows\<country>VatNumberFormatValidatorsConfig\<country>VatNumberFormatValidatorsConfig_** - preconfigured configuration class for vat number format validators for <Country> country; | ||
|
||
## <country>VatNumberFormatValidatorsConfig description | ||
|
||
A configuration class that provides a match for the vat number format validators for the country <country>. | ||
|
||
Class interface: | ||
- **_getCountry_** - returns <country> **_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. | ||
|
||
```php | ||
$config = new <country>VatNumberFormatValidatorsConfig(); | ||
|
||
$config->getCountry(); // returns <country> Country instance | ||
$config->getValidators(); // returns CountryVatFormatValidators with one item - instance of <country>VatFormatValidator | ||
``` | ||
|
||
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->getValidators(); // returns CountryVatFormatValidators with one item - $newDefaultValidator | ||
``` | ||
|
||
You can add additional validators to the default validator via the second constructor parameter. | ||
|
||
Attention - additional validators parameter must be instance of tuple **_CountryVatFormatValidators_**. | ||
And each additional validator must implement interface **_CountryVatFormatValidatorInterface_**. | ||
|
||
```php | ||
$firstAdditionalValidator = new FirstAdditionalValidator(); // instance of CountryVatFormatValidatorInterface | ||
$secondAdditionalValidator = new SecondAdditionalValidator(); // instance of CountryVatFormatValidatorInterface | ||
|
||
$config = new <country>VatNumberFormatValidatorsConfig( | ||
null, | ||
( | ||
new CountryVatFormatValidators( | ||
$firstAdditionalValidator, | ||
$secondAdditionalValidator | ||
) | ||
) | ||
); | ||
|
||
// returns CountryVatFormatValidators with three items: | ||
// default preconfigured validator by default - instance of <country>VatFormatValidator | ||
// $firstAdditionalValidator - from additional tuple | ||
// $secondAdditionalValidator - from additional tuple | ||
$config->getValidators(); | ||
``` | ||
|
||
You can also completely rebuild the configuration by passing the default validator and a tuple of additional validators to the config class constructor. | ||
|
||
```php | ||
$defaultValidator = new DefaultValidator(); // instance of CountryVatFormatValidatorInterface | ||
$firstAdditionalValidator = new FirstAdditionalValidator(); // instance of CountryVatFormatValidatorInterface | ||
$secondAdditionalValidator = new SecondAdditionalValidator(); // instance of CountryVatFormatValidatorInterface | ||
|
||
$config = new <country>VatNumberFormatValidatorsConfig( | ||
$defaultValidator, | ||
( | ||
new CountryVatFormatValidators( | ||
$firstAdditionalValidator, | ||
$secondAdditionalValidator | ||
) | ||
) | ||
); | ||
|
||
// returns CountryVatFormatValidators with three items: | ||
// $defaultValidator from constructor first parameter | ||
// $firstAdditionalValidator - from additional tuple | ||
// $secondAdditionalValidator - from additional tuple | ||
$config->getValidators(); | ||
``` | ||
|
||
More use case examples can be found in the package's unit tests. | ||
|
||
## Contributing | ||
|
||
Welcome to pull requests. If there is a major changes, first please open an issue for discussion. | ||
|
||
Please make sure to update tests as appropriate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?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"/> | ||
</project> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
// TODO: set name | ||
"name": "rocketfellows/<country>-vat-number-format-validators-config", | ||
"authors": [ | ||
{ | ||
"name": "Arslan Imamutdinov", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"license": "MIT", | ||
"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" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.5", | ||
"phpstan/phpstan": "^1.10", | ||
"squizlabs/php_codesniffer": "3.6.2", | ||
"roave/security-advisories": "dev-latest" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
// TODO: set namespace | ||
"rocketfellows\\<country>VatNumberFormatValidatorsConfig\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
// TODO: set namespace | ||
"rocketfellows\\<country>VatNumberFormatValidatorsConfig\\tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker-compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3" | ||
services: | ||
php: | ||
build: | ||
dockerfile: Dockerfile | ||
context: ./ | ||
volumes: | ||
- ./:/home/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker-compose -f docker-compose.yml up -d && \ | ||
docker-compose exec php composer install && \ | ||
docker-compose exec php composer dump-autoload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
sh ./docker-run-phpcs.sh && \ | ||
sh ./docker-run-phpstan.sh && \ | ||
sh ./docker-run-unit-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "=================== PHPCS ===================" | ||
|
||
eval "docker-compose exec php ./vendor/bin/phpcs -p -s --standard=phpcs.xml src tests" | ||
|
||
echo "\n=============================================" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "=================== PHPSTAN ===================" | ||
|
||
eval "docker-compose exec php ./vendor/bin/phpstan analyse" | ||
|
||
echo "\n=============================================" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "=================== UNIT-TESTS ===================" | ||
|
||
eval "docker-compose exec php ./vendor/bin/phpunit --colors=always --verbose --testdox" | ||
|
||
echo "\n=============================================" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<ruleset name="base-coding-style"> | ||
<description>Base component coding style</description> | ||
|
||
<rule ref="PSR12"/> | ||
|
||
<rule ref="PSR2.Methods.MethodDeclaration.Underscore"/> | ||
|
||
<rule ref="Generic.Formatting.SpaceAfterCast"/> | ||
|
||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/> | ||
|
||
<rule ref="Generic.Files.LineLength"> | ||
<properties> | ||
<property name="lineLimit" value="300"/> | ||
<property name="absoluteLineLimit" value="500"/> | ||
</properties> | ||
</rule> | ||
|
||
<rule ref="Squiz.Scope.MethodScope"/> | ||
|
||
<rule ref="Squiz.Classes.ValidClassName"/> | ||
|
||
<rule ref="PEAR.Functions.ValidDefaultValue"/> | ||
|
||
<rule ref="Zend.Files.ClosingTag"/> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
level: 5 | ||
paths: | ||
- src | ||
- tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
executionOrder="depends,defects" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true"> | ||
<coverage cacheDirectory=".phpunit.cache/code-coverage" processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
<report> | ||
<clover outputFile="clover.xml" /> | ||
</report> | ||
</coverage> | ||
|
||
<testsuites> | ||
<testsuite name="default"> | ||
<directory>./tests/unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
// TODO: namespace | ||
|
||
use arslanimamutdinov\ISOStandard3166\Country; | ||
use arslanimamutdinov\ISOStandard3166\ISO3166; | ||
use rocketfellows\CountryVatFormatValidatorInterface\CountryVatFormatValidatorInterface; | ||
use rocketfellows\SpecificCountryVatNumberFormatValidatorsConfig\SpecificCountryVatNumberFormatValidatorsConfig; | ||
|
||
class CountryVatNumberFormatValidatorsConfig extends SpecificCountryVatNumberFormatValidatorsConfig | ||
{ | ||
public function getCountry(): Country | ||
{ | ||
return ISO3166::COUNTRY(); | ||
} | ||
|
||
protected function getDefaultValidator(): CountryVatFormatValidatorInterface | ||
{ | ||
return new CountryVatFormatValidator(); | ||
} | ||
} |
Empty file.
Empty file.
Oops, something went wrong.