Git Product home page Git Product logo

php-documents's Introduction

Brazanation Documents

Build Status Codacy Badge Scrutinizer Code Quality Code Coverage StyleCI

A PHP library to provide Brazilian Documents safer, easier and fun!

Installation

Install the library using composer. Add the following to your composer.json:

{
    "require": {
        "brazanation/documents": "0.7.*"
    }
}

Now run the install command.

$ composer.phar install

or

$ composer require brazanation/documents 0.7.*

CPF (cadastro de pessoas físicas)

Registration of individuals or Tax Identification

use Brazanation\Documents\Cpf;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $cpf = new Cpf('06843273173');
    echo $cpf; // prints 06843273173
    echo $cpf->format(); // prints 068.432.731-73
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

CNPJ (cadastro nacional da pessoa jurídica)

Company Identification or National Register of Legal Entities

use Brazanation\Documents\Cnpj;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $cnpj = new Cnpj('99999090910270');
    echo $cnpj; // prints 99999090910270
    echo $cnpj->format(); // prints 99.999.090/9102-70
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

CNH (carteira nacional de habilitação)

National Driving License

use Brazanation\Documents\Cnh;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $cnh = new Cnh('83592802666');
    echo $cnh; // prints 83592802666
    echo $cnh->format(); // prints 83592802666
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

Chave de Acesso Sped (chave da NFe, CTe e MDFe)

Sped Access Key

Available models:

  • NFe
  • NFCe
  • CTe
  • CTeOther
  • MDFe
use Brazanation\Documents\Sped\NFe;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $accessKey = new NFe('52060433009911002506550120000007801267301613');
    echo $accessKey; // prints 52060433009911002506550120000007801267301613
    echo $accessKey->format(); // prints 5206 0433 0099 1100 2506 5501 2000 0007 8012 6730 1613
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

or generate your number

try {
    $nfeKey = NFe::generate(
        52,
        $generatedAt,
        new Cnpj('33009911002506'),
        12,
        780,
        EmissionType::normal(),
        26730161
    );
    echo $accessKey; // prints 52060433009911002506550120000007801267301613
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

PIS/PASEP (programa de integração social e programa de formação do patrimônio do servidor público)

Social Integration Program and Training Program of the Heritage of Public Servant

use Brazanation\Documents\PisPasep;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $pispasep = new PisPasep('51.82312.94-92');
    echo $pispasep; // prints 51823129492
    echo $pispasep->format(); // prints 51.82312.94-92
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

Título de Eleitor

Voter Registration

use Brazanation\Documents\Voter;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

try {
    $voter = new Voter('106644440302', 20, 42);
    echo $voter; // prints 106644440302
    echo $voter->getSection(); // prints 0020
    echo $voter->getZone(); // prints 042
}catch (InvalidDocumentException $e){
    echo $e->getMessage();
}

Inscrição Estadual

State Registration

use Brazanation\Documents\StateRegistration;
use Brazanation\Documents\Exception\InvalidDocument as  InvalidDocumentException;

$state = StateRegistration::AC('0100482300112');
echo $state; // prints 0100482300112
echo $state->format(); // prints 01.004.823/001-12

// for Commercial São Paulo
$state = StateRegistration::SP('110.042.490.114');
echo $state; // prints 110042490114
echo $state->format(); // prints 110.042.490.114

// for Rural Producer São Paulo
$state = StateRegistration::SP('P011004243002');
echo $state; // prints P011004243002
echo $state->format(); // prints P-01100424.3/002

Cartão Nacional de Saúde (SUS)

National Health Card

use Brazanation\Documents\Cns;

$cns = new Cns('242912018460005')
echo $cns; // prints 242912018460005
echo $cns->format(); // prints 242 9120 1846 0005

Renavam (Registro Nacional de Veículos Automotores)

National Registry of Motor Vehicles

use Brazanation\Documents\Renavam;

$renavam = new Renavam('61855253306')
echo $renavam; // prints 61855253306
echo $renavam->format(); // prints 6185.525330-6

Processos Judiciais

Numbers of legal proceedings related to Judiciary assessments

use Brazanation\Documents\JudiciaryProcess;

$procjud = new JudiciaryProcess('0048032982009809');
echo $procjud; //prints  0048032982009809
echo $procjud->format(); //prints  0048032.98.2009.8.09.0000

License

MIT, hell yeah!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.