Skip to content

Commit f0b2666

Browse files
authored
Initial commit
0 parents  commit f0b2666

23 files changed

+349
-0
lines changed

.github/workflows/ci-checks.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI-CHECKS
2+
3+
on: [push]
4+
5+
jobs:
6+
run-phpcs:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: php-actions/composer@v5
11+
- name: PHPCS analyze
12+
run: ./vendor/bin/phpcs -p -s --standard=phpcs.xml src tests
13+
run-php-stan:
14+
needs: run-phpcs
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: php-actions/composer@v5
19+
- name: PHPStan Static Analysis source code
20+
uses: php-actions/phpstan@v3
21+
with:
22+
configuration: ./phpstan.neon.dist
23+
run-php-unit-tests:
24+
needs: run-php-stan
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: php-actions/composer@v5
29+
- uses: php-actions/phpunit@v3
30+
with:
31+
version: 9.5.28
32+
bootstrap: vendor/autoload.php
33+
configuration: phpunit.xml
34+
args: --coverage-text
35+
run-assemble-php-unit-coverage:
36+
needs: run-php-unit-tests
37+
runs-on: ubuntu-latest
38+
steps:
39+
- uses: actions/checkout@v2
40+
- uses: php-actions/composer@v5
41+
- name: Run PHPUnit Tests
42+
uses: php-actions/phpunit@v3
43+
with:
44+
version: 9.5.28
45+
php_extensions: xdebug
46+
bootstrap: vendor/autoload.php
47+
configuration: phpunit.xml
48+
args: --coverage-text
49+
env:
50+
XDEBUG_MODE: coverage
51+
- name: Generate test coverage badge
52+
uses: timkrase/phpunit-coverage-badge@v1.2.0
53+
with:
54+
report: ./clover.xml
55+
coverage_badge_path: 'badge.svg'
56+
push_badge: true
57+
repo_token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
composer.phar
2+
/vendor/
3+
.idea
4+
.phpunit.result.cache
5+
6+
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
7+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
8+
# composer.lock

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM php:7.4-fpm
2+
RUN apt-get update && apt-get install -y \
3+
zlib1g-dev \
4+
libzip-dev \
5+
unzip \
6+
mc
7+
RUN docker-php-ext-install zip
8+
RUN mkdir -p /home/app
9+
WORKDIR /home/app
10+
COPY . /home/app
11+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Country vat format validator template description
2+
3+
## Implementation steps
4+
5+
1. Create repository use template for name: <ISO-3166-standard-alpha2-code>-vat-format-validator
6+
2. Update composer.json **name** attribute: rocketfellows/<ISO-3166-standard-alpha2-code>-vat-format-validator
7+
3. Update composer.json with autoload and autoload-dev sections by pattern:
8+
```php
9+
"autoload": {
10+
"psr-4": {
11+
"rocketfellows\\<ISO-3166-standard-alpha2-code>VatFormatValidator\\": "src/"
12+
}
13+
},
14+
"autoload-dev": {
15+
"psr-4": {
16+
"rocketfellows\\<ISO-3166-standard-alpha2-code>VatFormatValidator\\tests\\": "tests/"
17+
}
18+
}
19+
```
20+
3. Run docker-deploy.sh
21+
4. Implement unit test in test/unit directory
22+
5. Implement direct validator
23+
24+
# Templated readme
25+
26+
# <Country> vat format validator
27+
28+
![Code Coverage Badge](./badge.svg)
29+
30+
This component provides <Country> vat number format validator.
31+
32+
Implementation of interface **rocketfellows\CountryVatFormatValidatorInterface\CountryVatFormatValidatorInterface**
33+
34+
Depends on https://github.com/rocketfellows/country-vat-format-validator-interface
35+
36+
## Installation
37+
38+
```shell
39+
composer require rocketfellows/<ISO-3166-standard-alpha2-code>-vat-format-validator
40+
```
41+
42+
## Usage example
43+
44+
Valid <Country> vat number:
45+
46+
```php
47+
$validator = new <Country>VatFormatValidator();
48+
$validator->isValid('');
49+
$validator->isValid('');
50+
```
51+
52+
Returns:
53+
54+
```shell
55+
true
56+
true
57+
```
58+
59+
Invalid <Country> vat number:
60+
61+
```php
62+
$validator = new <Country>VatFormatValidator();
63+
$validator->isValid('');
64+
$validator->isValid('');
65+
```
66+
67+
```shell
68+
false
69+
false
70+
```
71+
72+
## Contributing
73+
74+
Welcome to pull requests. If there is a major changes, first please open an issue for discussion.
75+
76+
Please make sure to update tests as appropriate.
77+

badge.svg

Lines changed: 16 additions & 0 deletions
Loading

clover.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<coverage generated="1648587867">
3+
<project timestamp="1648587867">
4+
<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"/>
5+
</project>
6+
</coverage>

composer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "rocketfellows/country-vat-format-validator-template",
3+
"authors": [
4+
{
5+
"name": "Arslan Imamutdinov",
6+
"email": "ara.imamutdinov@gmail.com"
7+
}
8+
],
9+
"license": "MIT",
10+
"require": {
11+
"php": ">=7.4",
12+
"rocketfellows/country-vat-format-validator-interface": "^1.0"
13+
},
14+
"require-dev": {
15+
"phpunit/phpunit": "^8.5",
16+
"phpstan/phpstan": "^0.12.90",
17+
"squizlabs/php_codesniffer": "3.6.2"
18+
}
19+
}

docker-compose-down.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose down

docker-compose-up.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose up -d

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: "3"
2+
services:
3+
php:
4+
build:
5+
dockerfile: Dockerfile
6+
context: ./
7+
volumes:
8+
- ./:/home/app

0 commit comments

Comments
 (0)