@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | //& isolated, less than, greater than, quotation marks and apostrophes |
82 | 82 | //should be replaced by their html equivalent |
83 | 83 | $input = str_replace( |
84 | - ['& ','<','>','"',"'"], |
|
85 | - ['& ','<','>','"','''], |
|
84 | + ['& ', '<', '>', '"', "'"], |
|
85 | + ['& ', '<', '>', '"', '''], |
|
86 | 86 | $input |
87 | 87 | ); |
88 | 88 | $input = self::normalize($input); |
@@ -109,10 +109,10 @@ discard block |
||
109 | 109 | public static function squashCharacters($input) |
110 | 110 | { |
111 | 111 | $input = trim($input); |
112 | - $aFind = ['á','à','ã','â','é','ê','í','ó','ô','õ','ö','ú','ü', |
|
113 | - 'ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ö','Ú','Ü','Ç']; |
|
114 | - $aSubs = ['a','a','a','a','e','e','i','o','o','o','o','u','u', |
|
115 | - 'c','A','A','A','A','E','E','I','O','O','O','O','U','U','C']; |
|
112 | + $aFind = ['á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ö', 'ú', 'ü', |
|
113 | + 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ö', 'Ú', 'Ü', 'Ç']; |
|
114 | + $aSubs = ['a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'o', 'u', 'u', |
|
115 | + 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'O', 'U', 'U', 'C']; |
|
116 | 116 | return str_replace($aFind, $aSubs, $input); |
117 | 117 | } |
118 | 118 | |
@@ -126,21 +126,21 @@ discard block |
||
126 | 126 | public static function normalize($input) |
127 | 127 | { |
128 | 128 | //Carriage Return, Tab and Line Feed is not acceptable in strings |
129 | - $input = str_replace(["\r","\t","\n"], "", $input); |
|
129 | + $input = str_replace(["\r", "\t", "\n"], "", $input); |
|
130 | 130 | //Multiple spaces is not acceptable in strings |
131 | 131 | $input = preg_replace('/(?:\s\s+)/', ' ', $input); |
132 | 132 | //Only UTF-8 characters is acceptable |
133 | 133 | $input = Encoding::fixUTF8($input); |
134 | 134 | $input = preg_replace( |
135 | - '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. |
|
136 | - '|[\x00-\x7F][\x80-\xBF]+'. |
|
137 | - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. |
|
138 | - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. |
|
135 | + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . |
|
136 | + '|[\x00-\x7F][\x80-\xBF]+' . |
|
137 | + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . |
|
138 | + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . |
|
139 | 139 | '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', |
140 | 140 | '', |
141 | 141 | $input |
142 | 142 | ); |
143 | - $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
|
143 | + $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' . |
|
144 | 144 | '|\xED[\xA0-\xBF][\x80-\xBF]/S', '', $input); |
145 | 145 | //And no other control character is acceptable either |
146 | 146 | return preg_replace('/[[:cntrl:]]/', '', $input); |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | public static function clearProtocoledXML($string) |
209 | 209 | { |
210 | 210 | $procXML = self::clearXmlString($string); |
211 | - $aApp = array('nfe','cte','mdfe'); |
|
211 | + $aApp = array('nfe', 'cte', 'mdfe'); |
|
212 | 212 | foreach ($aApp as $app) { |
213 | 213 | $procXML = str_replace( |
214 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
215 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'"', |
|
214 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
215 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', |
|
216 | 216 | $procXML |
217 | 217 | ); |
218 | 218 | } |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | public static function removeSomeAlienCharsfromTxt($txt) |
228 | 228 | { |
229 | 229 | //remove CRs and TABs |
230 | - $txt = str_replace(["\r","\t"], "", $txt); |
|
230 | + $txt = str_replace(["\r", "\t"], "", $txt); |
|
231 | 231 | //remove multiple spaces |
232 | 232 | $txt = preg_replace('/(?:\s\s+)/', ' ', $txt); |
233 | 233 | //remove spaces at begin and end of fields |
234 | - $txt = str_replace(["| "," |"], "|", $txt); |
|
234 | + $txt = str_replace(["| ", " |"], "|", $txt); |
|
235 | 235 | return $txt; |
236 | 236 | } |
237 | 237 |