Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Sped Common Laravel Package

nfephp-org/sped-common

Biblioteca PHP com classes utilitárias compartilhadas para os projetos SPED da nfephp-org: NFe, CTe, MDFe, e-Financeira, eSfinge e eSocial. Reúne componentes comuns para facilitar integrações e reutilização de código.

View on GitHub
Deep Wiki
Context7

NFePHP\Common\Strings::class

Auxiliar class for strings treatment

Methods

replaceSpecialsChars($string)

Replace all specials characters from string and retuns only 128 basic characters. [a-z] [A-Z] [0-9] @ space , - . ; : $ %

NOTE: only UTF-8

    $str = "Á é ç ";
    $ret = Strings::replaceSpecialsChars($str);
    echo $ret; //A e c

##replaceUnacceptableCharacters($string) Clear inputs for build in XML, convert all characters to UTF-8, Replace & isolated, less than, greater than, quotation marks and apostrophes in html entities Remove Carriage Return, Tab and Line Feed Remove Multiple spaces is not acceptable in strings Remove all other control character

NOTE: string may be mixed UTF-8 and Latin1 (iso 8859-1) or Windows-1252

    $string = "Contribuições R$   200,00   IPI:   15% Caixa D'agua Rico & Rich < > \"   \t \r \n ";
    $string .= mb_convert_encoding(" teste ç Á ã é ø", 'ISO-8859-1'); 
    $ret = Strings::replaceUnacceptableCharacters($string);
    echo $ret; //Contribuições R$ 200,00 IPI: 15% Caixa D'agua Rico & Rich < > " teste ç Á ã é ø

clearXml()

Remove some attributes, prefixes, sulfixes and other control characters like \r \n \s \t

    $ret = Strings::clearXml($xml);
    echo $ret; //clean xml will returned

clearProtocoledXML()

Clears the xml after adding the protocol, removing repeated namespaces.

    $protxml = Strings::clearProt($xmlstring);
    echo $protxml; //clean xml will returned

deleteAllBetween()

Remove all characters between markers.

    $str = '<?xml version="1.0" encoding="UTF-8"?><nfeProc versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
    <NFe xmlns="http://www.portalfiscal.inf.br/nfe">';
    
    $ret = Strings::deleteAllBetween($str, '<?xml', '?>');
    echo $ret; //returns xml without encoding tag

randomString()

Creates a string ramdomically with the specified length.

    $randomStr = Strings::randomString(5);
    echo $randomStr; //zRT20

removeSomeAlienCharsfromTxt()

  • Removes [CR] and [TAB]

  • Removes duplicated [spaces]

  • Removes [spaces] after | (pipe)

  • Removes [spaces] before | (pipe)

  • @param string $txt

  • @return string

    $txtclean = Strings::removeSomeAlienCharsfromTxt($txt);
    echo $txtclean; //returns txt without this characters  
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log