An open API service indexing awesome lists of open source software.

https://github.com/germaniakg/vatidno

PHP Interfaces and traits for VAT ID numbers · PHP 5.6, PHP 7
https://github.com/germaniakg/vatidno

interfaces traits vat-number

Last synced: 2 months ago
JSON representation

PHP Interfaces and traits for VAT ID numbers · PHP 5.6, PHP 7

Awesome Lists containing this project

README

        

# Germania KG · VAT ID Number

**Interfaces, traits, and filters for dealing with VAT ID numbers**

[![Packagist](https://img.shields.io/packagist/v/germania-kg/vatidno.svg?style=flat)](https://packagist.org/packages/germania-kg/vatidno)
[![PHP version](https://img.shields.io/packagist/php-v/germania-kg/vatidno.svg)](https://packagist.org/packages/germania-kg/vatidno)
[![Tests](https://github.com/GermaniaKG/VatIdNo/actions/workflows/tests.yml/badge.svg)](https://github.com/GermaniaKG/VatIdNo/actions/workflows/tests.yml)

## Installation

```bash
$ composer require germania-kg/vatidno
```

## Interfaces

### VatIdNoProviderInterface

Provides a method **VatIdNo** to retrieve the VATIN as string.

```php
use Germania\VatIdNo\VatIdNoProviderInterface;

/**
* @return string
*/
public function getVatIdNo();
```

### VatIdNoAwareInterface

Extends *VatIdNoProviderInterface* and provides a method **setVatIdNo**, allowing you to set the VATIN.

```php
use Germania\VatIdNo\VatIdNoProviderInterface;

/**
* @param string $vatin
* @return self
*/
public function setVatIdNo( $vatin );
public function getVatIdNo();
```

## Traits

### VatIdNoProviderTrait

Implements the **VatIdNoProviderInterface** and provides a public property **vatin:**

```php
use Germania\VatIdNo\VatIdNoProviderInterface;
use Germania\VatIdNo\VatIdNoProviderTrait;

class MyClass implements VatIdNoProviderInterface {

use VatIdNoProviderTrait;

public function __construct( $vatin ) {
$this->vatin = $vatin;
}
}
```

### VatIdNoAwareTrait

Implements the **VatIdNoAwareInterface**. Utilizes the *VatIdNoProviderTrait*.

```php
use Germania\VatIdNo\VatIdNoAwareInterface;
use Germania\VatIdNo\VatIdNoAwareTrait;

class MyClass implements VatIdNoAwareInterface {
use VatIdNoAwareTrait;
}

// Simple example
$object1 = new MyClass;
$object1->setVatIdNo( "XY000000" );

// Fluent interface
echo $object1->setVatIdNo( "XY000000" )->vatin;

// Setting using VatIdNoProviderInterface
$object2 = new MyClass;
$object2->setVatIdNo( $object1 );

```

## Filters

### WithVatIdNoFilterIterator

Filter for records that *do provide* a VATIN. These may be:

- Arrays with `vatin` key, and non-empty value
- Objects with `vatin` property, and non-empty value
- Instances of `VatIdNoProviderInterface` where *getVatIdNo* results *not empty*

```php