Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala authored and drupol committed Mar 16, 2020
0 parents commit 53446b2
Show file tree
Hide file tree
Showing 81 changed files with 18,653 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
comment: off
coverage:
status:
project: off
patch: off

25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2
indent_style = space

[composer.json]
indent_size = 4
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/tests export-ignore
/phpunit.xml.dist export-ignore
/.gitignore export-ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
composer.lock
phpunit.xml
15 changes: 15 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
inherit: true

build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]

checks:
php:
code_rating: true
duplication: true

filter:
paths: [src/*, tests/*]
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
sudo: false

language: php

dist: trusty

cache:
directories:
- $HOME/.composer/cache/files

matrix:
fast_finish: true
include:
- php: 7.1
env:
- PHPUNIT_TEST=1
- PHPCS_TEST=1
- PHPUNIT_COVERAGE_TEST=1
- php: 7.2
env:
- PHPUNIT_TEST=1
- php: 7.3
env:
- PHPUNIT_TEST=1
- php: 7.4
env:
- PHPUNIT_TEST=1

before_script:
# Extra $PATH
- export PATH=~/.composer/vendor/bin:$PATH

# Init PHP
- phpenv rehash
- phpenv config-rm xdebug.ini || true
- echo 'memory_limit = 2048M' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

# Install composer dependencies
- composer validate
- if [[ $PHPCS_TEST ]]; then composer global require squizlabs/php_codesniffer:^3 --prefer-dist --no-interaction --no-progress --no-suggest -o; fi
- composer install --prefer-source --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile

script:
- if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit; fi
- if [[ $PHPCS_TEST ]]; then composer run-script lint; fi
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi

after_success:
- if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi
16 changes: 16 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The MIT License (MIT)

Copyright (c) 2020 Thomas Portelange

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the _Software_), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED **AS IS**, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
92 changes: 92 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Taxpayer Identification Number (TIN) Validator

[![Build Status](https://travis-ci.org/lekoala/tin.svg?branch=master)](https://travis-ci.org/lekoala/tin)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/lekoala/tin/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/lekoala/tin/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/lekoala/tin/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/lekoala/tin/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/lekoala/tin/badges/build.png?b=master)](https://scrutinizer-ci.com/g/lekoala/tin/build-status/master)
[![codecov.io](https://codecov.io/github/lekoala/tin/coverage.svg?branch=master)](https://codecov.io/github/lekoala/tin?branch=master)

[![Latest Stable Version](https://poser.pugx.org/lekoala/tin/version)](https://packagist.org/packages/lekoala/tin)
[![Latest Unstable Version](https://poser.pugx.org/lekoala/tin/v/unstable)](//packagist.org/packages/lekoala/tin)
[![Total Downloads](https://poser.pugx.org/lekoala/tin/downloads)](https://packagist.org/packages/lekoala/tin)
[![License](https://poser.pugx.org/lekoala/tin/license)](https://packagist.org/packages/lekoala/tin)
[![Monthly Downloads](https://poser.pugx.org/lekoala/tin/d/monthly)](https://packagist.org/packages/lekoala/tin)
[![Daily Downloads](https://poser.pugx.org/lekoala/tin/d/daily)](https://packagist.org/packages/lekoala/tin)

[![Dependency Status](https://www.versioneye.com/php/lekoala:tin/badge.svg)](https://www.versioneye.com/php/lekoala:tin)
[![Reference Status](https://www.versioneye.com/php/lekoala:tin/reference_badge.svg?style=flat)](https://www.versioneye.com/php/lekoala:tin/references)

A library to validate TIN numbers for individuals. This is based on a java library,
this is why the code does not reflect best practices in php.

Supported countries are:
- Austria (AT)
- Belgium (BE)
- Bulgaria (BG)
- Croatia (HR)
- Cyprus (CY)
- Czech Republic (CZ) - no check digit (but possible czechphp/national-identification-number-validator)
- Denmark (DK)
- Estonia (EE)
- Finland (FI)
- France (FR)
- Germany (DE)
- Greece (GR) - only size
- Hungary (HU)
- Ireland (IE)
- Italy (IT)
- Latvia (LV) - no check digit
- Lithuania (LT)
- Luxembourg (LU)
- Malta (MT) - no check digit
- Netherlands (NL)
- Poland (PL)
- Portugal (PT)
- Romania (RO) - no check digit
- Slovakia (SK) - only structure
- Slovenia (SI)
- Spain (ES)
- Sweden (SE)
- United Kingdom (UK) - only structure

If your country is not there, feel free to open an issue with your country code and
a link to the specification. Ideally, if you can provide a PR with the algorithm and the
test that would be even better :-)

## Installation

Run

```
$ composer require lekoala/tin
```

## Usage

To simply check the validity of a number

$result = TINValid::checkTIN($countryCode, $number);

If you want to get the reason why a number is invalid, you can use

try {
TINValid::validateTIN($countryCode, $number);
}
catch(TINValidationException $e) {
}

If you want to see if a country is supported or not, you can simply use

$result = TINValid::isCountrySupported('be');

## Links

[`TIN Algorithms - Public - Functional Specification`](<https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN Algorithms-Public.docx>)

[`Taxpayer Identification Number`](https://en.wikipedia.org/wiki/Taxpayer_Identification_Number)

## License

This package is licensed using the MIT License.
Please have a look at [`LICENSE.md`](LICENSE.md).
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "lekoala/tin",
"type": "library",
"description": "Provide validation tools for Taxpayer Identification Number",
"homepage": "https://github.com/lekoala/tin",
"license": "MIT",
"authors": [{
"name": "Thomas Portelange",
"email": "thomas@lekoala.be"
}],
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.5"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"LeKoala\\Tin\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"LeKoala\\Tin\\Test\\": "tests/"
}
},
"scripts": {
"lint": "phpcs src/ tests/",
"lint-clean": "phpcbf src/ tests/",
"test": "phpunit -v"
},
"support": {
"issues": "https://github.com/lekoala/tin/issues",
"source": "https://github.com/lekoala/tin"
}
}
Loading

0 comments on commit 53446b2

Please sign in to comment.