Skip to content

Commit 0d8d6f9

Browse files
first commit
0 parents  commit 0d8d6f9

20 files changed

+1249
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor
2+
composer.lock

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: php
2+
3+
php:
4+
- 7.0
5+
6+
install:
7+
- travis_retry composer install --no-interaction --prefer-source
8+
9+
script:
10+
- vendor/bin/phpunit

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-2017 Danny van Kooten <hi@dvk.co>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
vat.php
2+
================
3+
4+
<a href="https://travis-ci.org/dannyvankooten/vat.php"><img src="https://img.shields.io/travis/dannyvankooten/vat.php/master.svg?style=flat-square" alt="Build Status"></img></a>
5+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Software License"></img></a>
6+
7+
vat.php is a simple PHP library which helps you to deal with European VAT rules. It helps you...
8+
9+
- Grab up-to-date VAT rates for any European member state
10+
- Validate VAT numbers (by format or existence)
11+
- Work with ISO 3166-1 alpha-2 country codes and determine whether they're part of the EU.
12+
- Geolocate IP addresses
13+
14+
The library uses jsonvat.com to obtain its data for the VAT rates. Full details can be seen [here](https://github.com/adamcooke/vat-rates).
15+
For VAT number validation, it uses [VIES VAT number validation](http://ec.europa.eu/taxation_customs/vies/).
16+
17+
## Installation
18+
19+
[PHP](https://php.net) 5.6+ is required. For VAT number existence checking, the PHP SOAP extension is required as well.
20+
21+
To get the latest version of vat.php, simply require the project using [Composer](https://getcomposer.org):
22+
23+
```bash
24+
$ composer require dannyvankooten/vat.php
25+
```
26+
27+
## Usage
28+
29+
This library exposes 3 main classes to interact with, `Rates`, `Countries` and `Validator`.
30+
31+
#### Fetching VAT rates.
32+
33+
```php
34+
$rates = new DvK\Vat\Rates\Rates();
35+
$rates->country('NL'); // 21
36+
$rates->country('NL', 'standard'); // 21
37+
$rates->country('NL', 'reduced'); // 6
38+
$rates->all(); // array in country code => rates format
39+
```
40+
41+
#### Validating a VAT number
42+
43+
```php
44+
$validator = new DvK\Vat\Validator();
45+
$validator->validate('NL50123'); // false
46+
$validator->validateFormat('NL203458239B01'); // true (checks format)
47+
$validator->validateExistence('NL203458239B01') // false (checks existence)
48+
$validator->validate('NL203458239B01'); // false (checks format + existence)
49+
```
50+
51+
52+
#### Dealing with countries & geolocation
53+
54+
```php
55+
$countries = new DvK\Vat\Countries();
56+
$countries->all(); // array of country codes + names
57+
$countries->name('NL') // Netherlands
58+
$countries->europe(); // array of EU country codes + names
59+
$countries->inEurope('NL'); // true
60+
$countries->ip('8.8.8.8'); // US
61+
```
62+
63+
## License
64+
65+
vat.php is licensed under [The MIT License (MIT)](LICENSE).

composer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "dannyvankooten/vat.php",
3+
"description": "PHP library for dealing with VAT in Europe",
4+
"keywords": ["vat"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Danny van Kooten",
9+
"email": "hi@dvk.co"
10+
}
11+
],
12+
"require": {
13+
"php": ">=7.0"
14+
},
15+
"require-dev": {
16+
"phpunit/phpunit": "^5.0"
17+
},
18+
"autoload": {
19+
"psr-4": {
20+
"DvK\\Vat\\": "src/"
21+
}
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"DvK\\Tests\\Vat\\": "tests/"
26+
}
27+
},
28+
"config": {
29+
"preferred-install": "dist"
30+
},
31+
"prefer-stable": true
32+
}

phpunit.xml.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
beStrictAboutTestsThatDoNotTestAnything="true"
5+
beStrictAboutOutputDuringTests="true"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
failOnRisky="true"
12+
failOnWarning="true"
13+
processIsolation="false"
14+
stopOnError="false"
15+
stopOnFailure="false"
16+
verbose="true"
17+
>
18+
<testsuites>
19+
<testsuite name="VAT Test Suite">
20+
<directory suffix="Test.php">./tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
<filter>
24+
<whitelist processUncoveredFilesFromWhitelist="true">
25+
<directory suffix=".php">./src</directory>
26+
</whitelist>
27+
</filter>
28+
</phpunit>

0 commit comments

Comments
 (0)