-
Notifications
You must be signed in to change notification settings - Fork 61
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 0d8d6f9
Showing
20 changed files
with
1,249 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,2 @@ | ||
vendor | ||
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,10 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
|
||
install: | ||
- travis_retry composer install --no-interaction --prefer-source | ||
|
||
script: | ||
- vendor/bin/phpunit |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016-2017 Danny van Kooten <[email protected]> | ||
|
||
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. |
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,65 @@ | ||
vat.php | ||
================ | ||
|
||
<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> | ||
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square" alt="Software License"></img></a> | ||
|
||
vat.php is a simple PHP library which helps you to deal with European VAT rules. It helps you... | ||
|
||
- Grab up-to-date VAT rates for any European member state | ||
- Validate VAT numbers (by format or existence) | ||
- Work with ISO 3166-1 alpha-2 country codes and determine whether they're part of the EU. | ||
- Geolocate IP addresses | ||
|
||
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). | ||
For VAT number validation, it uses [VIES VAT number validation](http://ec.europa.eu/taxation_customs/vies/). | ||
|
||
## Installation | ||
|
||
[PHP](https://php.net) 5.6+ is required. For VAT number existence checking, the PHP SOAP extension is required as well. | ||
|
||
To get the latest version of vat.php, simply require the project using [Composer](https://getcomposer.org): | ||
|
||
```bash | ||
$ composer require dannyvankooten/vat.php | ||
``` | ||
|
||
## Usage | ||
|
||
This library exposes 3 main classes to interact with, `Rates`, `Countries` and `Validator`. | ||
|
||
#### Fetching VAT rates. | ||
|
||
```php | ||
$rates = new DvK\Vat\Rates\Rates(); | ||
$rates->country('NL'); // 21 | ||
$rates->country('NL', 'standard'); // 21 | ||
$rates->country('NL', 'reduced'); // 6 | ||
$rates->all(); // array in country code => rates format | ||
``` | ||
|
||
#### Validating a VAT number | ||
|
||
```php | ||
$validator = new DvK\Vat\Validator(); | ||
$validator->validate('NL50123'); // false | ||
$validator->validateFormat('NL203458239B01'); // true (checks format) | ||
$validator->validateExistence('NL203458239B01') // false (checks existence) | ||
$validator->validate('NL203458239B01'); // false (checks format + existence) | ||
``` | ||
|
||
|
||
#### Dealing with countries & geolocation | ||
|
||
```php | ||
$countries = new DvK\Vat\Countries(); | ||
$countries->all(); // array of country codes + names | ||
$countries->name('NL') // Netherlands | ||
$countries->europe(); // array of EU country codes + names | ||
$countries->inEurope('NL'); // true | ||
$countries->ip('8.8.8.8'); // US | ||
``` | ||
|
||
## License | ||
|
||
vat.php is licensed under [The MIT License (MIT)](LICENSE). |
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,32 @@ | ||
{ | ||
"name": "dannyvankooten/vat.php", | ||
"description": "PHP library for dealing with VAT in Europe", | ||
"keywords": ["vat"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Danny van Kooten", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"DvK\\Vat\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"DvK\\Tests\\Vat\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"preferred-install": "dist" | ||
}, | ||
"prefer-stable": true | ||
} |
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
beStrictAboutTestsThatDoNotTestAnything="true" | ||
beStrictAboutOutputDuringTests="true" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="VAT Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
Oops, something went wrong.