PHP code example of fgsl / cnpj

1. Go to this page and download the library: Download fgsl/cnpj library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fgsl / cnpj example snippets


class JValidatorTest extends TestCase
{
    public function testCNPJSemFormatacao()
    {
        $validator = new JValidator();
        $cnpjSemDV = '12ABC34501DE';
        $cnpjComDV = $cnpjSemDV . $validator->calculaDV($cnpjSemDV);
        $this->assertTrue($validator->isValid($cnpjComDV));
    }

    public function testCNPJComFormatacao()
    {
        $validator = new JValidator();
        $cnpjSemDV = '12.ABC.345/01DE';
        $cnpjComDV = $cnpjSemDV . '-' . $validator->calculaDV($cnpjSemDV);
        $this->assertTrue($validator->isValid($cnpjComDV));
    }
}