PHP code example of enricky / cnpj-manager

1. Go to this page and download the library: Download enricky/cnpj-manager 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/ */

    

enricky / cnpj-manager example snippets


use Enricky\CnpjManager\Cnpj;

$cnpj = Cnpj::generate();
echo $cnpj; // 35.796.587/0001-71

$cnpjValido = Cnpj::validate('56.616.297/0001-79');
var_dump($cnpjValido); //bool(true)

$cnpjInvalido = Cnpj::validate('22.222.222/2222-22');
var_dump($cnpjInvalido); //bool(false)

$cnpjFormatado = Cnpj::format('56616297000179');
echo $cnpjFormatado; // 56.616.297/0001-79

$formatoValido = Cnpj::validateFormat('22.222.222/2222-22');
var_dump($formatoValido); //bool(true)

$formatoInvalido = Cnpj::validateFormat('22/222/222/2222/22');
var_dump($formatoInvalido); //bool(false)

$cnpjLimpo = Cnpj::cleanUp('56.616.297/0001-79');
echo $cnpjLimpo; // 56616297000179