Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Commit

Permalink
Add Countries class containing helper methods to deal with EC count…
Browse files Browse the repository at this point in the history
…ry codes and simple geo-ip.
  • Loading branch information
dannyvankooten committed Apr 10, 2016
1 parent 0eee812 commit 65e4f84
Show file tree
Hide file tree
Showing 9 changed files with 466 additions and 79 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- hhvm
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Laravel VAT

Laravel VAT is a simple Laravel library which helps you in dealing with European VAT rules. It helps you...

- Grab (current) VAT rates for any European member state
- Validate VAT numbers
- 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, this uses the [VIES VAT number validation](http://ec.europa.eu/taxation_customs/vies/).

## Installation

Either [PHP](https://php.net) 5.5+ or [HHVM](http://hhvm.com) 3.6+ are required. For VAT number validation, the PHP SOAP extension is required as well.
Either [PHP](https://php.net) 5.6+ or [HHVM](http://hhvm.com) 3.6+ are required. For VAT number validation, the PHP SOAP extension is required as well.

To get the latest version of Laravel VAT, simply require the project using [Composer](https://getcomposer.org):

Expand All @@ -30,6 +32,8 @@ You can register facades in the `aliases` key of your `config/app.php` file if y

* `'VatRates' => 'DvK\Laravel\Vat\Facades\Rates'`
* `'VatValidator' => 'DvK\Laravel\Vat\Facades\Validator'`
* `'Countries' => 'DvK\Laravel\Vat\Facades\Countries'`


## Usage

Expand All @@ -38,6 +42,7 @@ If you registered the facades then using an instance of the classes is as easy a
```php
use DvK\Laravel\Vat\Facades\Rates;
use DvK\Laravel\Vat\Facades\Validator;
use DvK\Laravel\Vat\Facades\Countries;

Rates::country( 'NL' ); // 21
Rates::country( 'NL', 'reduced' ); // 6
Expand All @@ -48,7 +53,11 @@ Validator::validateFormat('NL203458239B01'); // true (checks just format)
Validator::validate('NL203458239B01'); // false (checks format + existence)
Validator::validate('NL203458239B01', 'GB'); // false (checks format + existence + country match)

Validator::isEuCountry('NL'); // true
Countries::inEurope('NL'); // true
Countries::name('NL') // Netherlands
Countries::all(); // array of country codes + names
Countries::europe(); array of EU country codes + names
Countries::ip('8.8.8.8'); // US
```

If you'd prefer to use dependency injection, you can easily inject the class like this.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
}
],
"require": {
"php": ">=5.5.9"
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "^4.8|^5.0"
"phpunit/phpunit": "^5.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 65e4f84

Please sign in to comment.