@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | public static function replaceSpecialsChars($string) |
| 26 | 26 | { |
| 27 | 27 | $string = trim($string); |
| 28 | - $aFind = ['&','á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü', |
|
| 29 | - 'ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç']; |
|
| 30 | - $aSubs = ['e','a','a','a','a','e','e','i','o','o','o','u','u', |
|
| 31 | - 'c','A','A','A','A','E','E','I','O','O','O','U','U','C']; |
|
| 28 | + $aFind = ['&', 'á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü', |
|
| 29 | + 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç']; |
|
| 30 | + $aSubs = ['e', 'a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u', |
|
| 31 | + 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C']; |
|
| 32 | 32 | $newstr = str_replace($aFind, $aSubs, $string); |
| 33 | 33 | $newstr = preg_replace("/[^a-zA-Z0-9 @#,-_.;:$%\/]/", "", $newstr); |
| 34 | 34 | $newstr = preg_replace("/[<>]/", "", $newstr); |
@@ -53,23 +53,23 @@ discard block |
||
| 53 | 53 | } |
| 54 | 54 | //& isolated, less than, greater than, quotation marks and apostrophes |
| 55 | 55 | //should be replaced by their html equivalent |
| 56 | - $input = str_replace(['& ','<','>','"',"'"], ['& ','<','>','"','''], $input); |
|
| 56 | + $input = str_replace(['& ', '<', '>', '"', "'"], ['& ', '<', '>', '"', '''], $input); |
|
| 57 | 57 | //Carriage Return, Tab and Line Feed is not acceptable in strings |
| 58 | - $input = str_replace(["\r","\t","\n"], "", $input); |
|
| 58 | + $input = str_replace(["\r", "\t", "\n"], "", $input); |
|
| 59 | 59 | //Multiple spaces is not acceptable in strings |
| 60 | 60 | $input = preg_replace('/(?:\s\s+)/', ' ', $input); |
| 61 | 61 | //Only UTF-8 characters is acceptable |
| 62 | 62 | $input = Encoding::fixUTF8($input); |
| 63 | 63 | $input = preg_replace( |
| 64 | - '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. |
|
| 65 | - '|[\x00-\x7F][\x80-\xBF]+'. |
|
| 66 | - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. |
|
| 67 | - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. |
|
| 64 | + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . |
|
| 65 | + '|[\x00-\x7F][\x80-\xBF]+' . |
|
| 66 | + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . |
|
| 67 | + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . |
|
| 68 | 68 | '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', |
| 69 | 69 | '', |
| 70 | 70 | $input |
| 71 | 71 | ); |
| 72 | - $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
|
| 72 | + $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' . |
|
| 73 | 73 | '|\xED[\xA0-\xBF][\x80-\xBF]/S', '', $input); |
| 74 | 74 | //And no other control character is acceptable either |
| 75 | 75 | $input = preg_replace('/[[:cntrl:]]/', '', $input); |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | public static function clearProtocoledXML($string) |
| 139 | 139 | { |
| 140 | 140 | $procXML = self::clearXmlString($string); |
| 141 | - $aApp = array('nfe','cte','mdfe'); |
|
| 141 | + $aApp = array('nfe', 'cte', 'mdfe'); |
|
| 142 | 142 | foreach ($aApp as $app) { |
| 143 | 143 | $procXML = str_replace( |
| 144 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 145 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'"', |
|
| 144 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 145 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', |
|
| 146 | 146 | $procXML |
| 147 | 147 | ); |
| 148 | 148 | } |
@@ -157,11 +157,11 @@ discard block |
||
| 157 | 157 | public static function removeSomeAlienCharsfromTxt($txt) |
| 158 | 158 | { |
| 159 | 159 | //remove CRs and TABs |
| 160 | - $txt = str_replace(["\r","\t"], "", $txt); |
|
| 160 | + $txt = str_replace(["\r", "\t"], "", $txt); |
|
| 161 | 161 | //remove multiple spaces |
| 162 | 162 | $txt = preg_replace('/(?:\s\s+)/', ' ', $txt); |
| 163 | 163 | //remove spaces at begin and end of fields |
| 164 | - $txt = str_replace(["| "," |"], "|", $txt); |
|
| 164 | + $txt = str_replace(["| ", " |"], "|", $txt); |
|
| 165 | 165 | return $txt; |
| 166 | 166 | } |
| 167 | 167 | |