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.
Auxiliar class for strings treatment
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 ç Á ã é ø
Remove some attributes, prefixes, sulfixes and other control characters like \r \n \s \t
$ret = Strings::clearXml($xml);
echo $ret; //clean xml will returned
Clears the xml after adding the protocol, removing repeated namespaces.
$protxml = Strings::clearProt($xmlstring);
echo $protxml; //clean xml will returned
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
Creates a string ramdomically with the specified length.
$randomStr = Strings::randomString(5);
echo $randomStr; //zRT20
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
How can I help you explore Laravel packages today?