2017 © Pedro Peláez
 

library vatidno

Interfaces and traits for VAT ID numbers.

image

germania-kg/vatidno

Interfaces and traits for VAT ID numbers.

  • Tuesday, April 17, 2018
  • by germania-kg
  • Repository
  • 2 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Germania KG · VAT ID Number

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

Packagist PHP version Build Status Scrutinizer Code Quality Code Coverage Build Status, (*2)

Installation

$ composer require germania-kg/vatidno

Interfaces

VatIdNoProviderInterface

Provides a method VatIdNo to retrieve the VATIN as string., (*3)

use Germania\VatIdNo\VatIdNoProviderInterface;

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

VatIdNoAwareInterface

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

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:, (*5)

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., (*6)

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:, (*7)

  • 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
use Germania\VatIdNo\Filters\WithVatIdNoFilterIterator;

$records = new \ArrayIterator( ask_database() );

// Allow custom field names in arrays or objects
$records_with_vatin = new WithoutVatIdNoFilterIterator( $records );
$records_with_vatin = new WithoutVatIdNoFilterIterator( $records, "ust_id" );

foreach( $records_with_vatin as $item):
 // Do things like validating
endforeach;

WithoutVatIdNoFilterIterator

Filter for records that do not provide a VATIN. These may be:, (*8)

  • Arrays lacking vatin key, or empty vatin element
  • Objects lacking vatin property, or empty vatin property
  • Instances of VatIdNoProviderInterface where getVatIdNo results empty
<?php
use Germania\VatIdNo\Filters\WithoutVatIdNoFilterIterator;

$records = new \ArrayIterator( ask_database() );

// Allow custom field names in arrays or objects
$records_lacking = new WithoutVatIdNoFilterIterator( $records );
$records_lacking = new WithoutVatIdNoFilterIterator( $records, "ust_id" );

foreach( $records_lacking as item):
 //...
endforeach;

Validation

To validate the VAT ID numbers, use a dedicated package like David de Boer's ddeboer/vatin package., (*9)

Development

$ git clone https://github.com/GermaniaKG/VatIdNo.git
$ cd VatIdNo
$ composer install

Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:, (*10)

$ composer test
# or
$ vendor/bin/phpunit

The Versions

17/04 2018

dev-develop

dev-develop

Interfaces and traits for VAT ID numbers.

  Sources   Download

proprietary

The Development Requires

by Carsten Witt

traits filters vat interfaces vat id number vat id no vatin vatid

17/04 2018

dev-master

9999999-dev

Interfaces and traits for VAT ID numbers.

  Sources   Download

proprietary

The Development Requires

by Carsten Witt

traits filters vat interfaces vat id number vat id no vatin vatid

17/04 2018

1.0.1

1.0.1.0

Interfaces and traits for VAT ID numbers.

  Sources   Download

proprietary

The Development Requires

by Carsten Witt

traits filters vat interfaces vat id number vat id no vatin vatid

16/04 2018

1.0.0

1.0.0.0

Interfaces and traits for VAT ID numbers.

  Sources   Download

proprietary

The Development Requires

by Carsten Witt

traits filters vat interfaces vat id number vat id no