@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | class Signer |
| 34 | 34 | { |
| 35 | - const CANONICAL = [true,false,null,null]; |
|
| 35 | + const CANONICAL = [true, false, null, null]; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Make Signature tag |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
| 119 | 119 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
| 120 | 120 | } |
| 121 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 121 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 122 | 122 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
| 123 | 123 | $idSigned = trim($node->getAttribute($mark)); |
| 124 | 124 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -248,7 +248,7 @@ |
||
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * Return uid from user |
| 251 | - * @return string |
|
| 251 | + * @return integer |
|
| 252 | 252 | */ |
| 253 | 253 | protected function uid() |
| 254 | 254 | { |
@@ -269,8 +269,8 @@ discard block |
||
| 269 | 269 | . $this->uid() |
| 270 | 270 | .'/' |
| 271 | 271 | . $mapto |
| 272 | - . '/' ; |
|
| 273 | - $folderRealPath = sys_get_temp_dir().$path; |
|
| 272 | + . '/'; |
|
| 273 | + $folderRealPath = sys_get_temp_dir() . $path; |
|
| 274 | 274 | } |
| 275 | 275 | if (substr($folderRealPath, -1) !== '/') { |
| 276 | 276 | $folderRealPath .= '/'; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | if (!$this->filesystem->has($name)) { |
| 560 | 560 | return $name; |
| 561 | 561 | } |
| 562 | - $this->randomName($n+5); |
|
| 562 | + $this->randomName($n + 5); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | //remove todos os arquivos antigos |
| 579 | 579 | $contents = $this->filesystem->listContents($this->certsdir, true); |
| 580 | 580 | $dt = new \DateTime(); |
| 581 | - $tint = new \DateInterval("PT".$this->waitingTime."M"); |
|
| 581 | + $tint = new \DateInterval("PT" . $this->waitingTime . "M"); |
|
| 582 | 582 | $tint->invert = 1; |
| 583 | 583 | $tsLimit = $dt->add($tint)->getTimestamp(); |
| 584 | 584 | foreach ($contents as $item) { |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | //& isolated, less than, greater than, quotation marks and apostrophes |
| 50 | 50 | //should be replaced by their html equivalent |
| 51 | 51 | $input = str_replace( |
| 52 | - ['& ','<','>','"',"'"], |
|
| 53 | - ['& ','<','>','"','''], |
|
| 52 | + ['& ', '<', '>', '"', "'"], |
|
| 53 | + ['& ', '<', '>', '"', '''], |
|
| 54 | 54 | $input |
| 55 | 55 | ); |
| 56 | 56 | $input = self::normalize($input); |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | public static function squashCharacters($input) |
| 78 | 78 | { |
| 79 | 79 | $input = trim($input); |
| 80 | - $aFind = ['á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü', |
|
| 81 | - 'ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç']; |
|
| 82 | - $aSubs = ['a','a','a','a','e','e','i','o','o','o','u','u', |
|
| 83 | - 'c','A','A','A','A','E','E','I','O','O','O','U','U','C']; |
|
| 80 | + $aFind = ['á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü', |
|
| 81 | + 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç']; |
|
| 82 | + $aSubs = ['a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u', |
|
| 83 | + 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C']; |
|
| 84 | 84 | return str_replace($aFind, $aSubs, $input); |
| 85 | 85 | } |
| 86 | 86 | |
@@ -94,21 +94,21 @@ discard block |
||
| 94 | 94 | public static function normalize($input) |
| 95 | 95 | { |
| 96 | 96 | //Carriage Return, Tab and Line Feed is not acceptable in strings |
| 97 | - $input = str_replace(["\r","\t","\n"], "", $input); |
|
| 97 | + $input = str_replace(["\r", "\t", "\n"], "", $input); |
|
| 98 | 98 | //Multiple spaces is not acceptable in strings |
| 99 | 99 | $input = preg_replace('/(?:\s\s+)/', ' ', $input); |
| 100 | 100 | //Only UTF-8 characters is acceptable |
| 101 | 101 | $input = Encoding::fixUTF8($input); |
| 102 | 102 | $input = preg_replace( |
| 103 | - '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. |
|
| 104 | - '|[\x00-\x7F][\x80-\xBF]+'. |
|
| 105 | - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. |
|
| 106 | - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. |
|
| 103 | + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . |
|
| 104 | + '|[\x00-\x7F][\x80-\xBF]+' . |
|
| 105 | + '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . |
|
| 106 | + '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . |
|
| 107 | 107 | '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', |
| 108 | 108 | '', |
| 109 | 109 | $input |
| 110 | 110 | ); |
| 111 | - $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'. |
|
| 111 | + $input = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' . |
|
| 112 | 112 | '|\xED[\xA0-\xBF][\x80-\xBF]/S', '', $input); |
| 113 | 113 | //And no other control character is acceptable either |
| 114 | 114 | return preg_replace('/[[:cntrl:]]/', '', $input); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | public static function clearProtocoledXML($string) |
| 177 | 177 | { |
| 178 | 178 | $procXML = self::clearXmlString($string); |
| 179 | - $aApp = array('nfe','cte','mdfe'); |
|
| 179 | + $aApp = array('nfe', 'cte', 'mdfe'); |
|
| 180 | 180 | foreach ($aApp as $app) { |
| 181 | 181 | $procXML = str_replace( |
| 182 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 183 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'"', |
|
| 182 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 183 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', |
|
| 184 | 184 | $procXML |
| 185 | 185 | ); |
| 186 | 186 | } |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | public static function removeSomeAlienCharsfromTxt($txt) |
| 196 | 196 | { |
| 197 | 197 | //remove CRs and TABs |
| 198 | - $txt = str_replace(["\r","\t"], "", $txt); |
|
| 198 | + $txt = str_replace(["\r", "\t"], "", $txt); |
|
| 199 | 199 | //remove multiple spaces |
| 200 | 200 | $txt = preg_replace('/(?:\s\s+)/', ' ', $txt); |
| 201 | 201 | //remove spaces at begin and end of fields |
| 202 | - $txt = str_replace(["| "," |"], "|", $txt); |
|
| 202 | + $txt = str_replace(["| ", " |"], "|", $txt); |
|
| 203 | 203 | return $txt; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -194,8 +194,8 @@ |
||
| 194 | 194 | $mdec = strpos($n[1], '-'); |
| 195 | 195 | $p = explode('.', $value); |
| 196 | 196 | |
| 197 | - $ndec = !empty($p[1]) ? strlen($p[1]) : 0;//decimal digits |
|
| 198 | - $nint = strlen($p[0]);//integer digits |
|
| 197 | + $ndec = !empty($p[1]) ? strlen($p[1]) : 0; //decimal digits |
|
| 198 | + $nint = strlen($p[0]); //integer digits |
|
| 199 | 199 | if ($nint > $n[0]) { |
| 200 | 200 | throw new \InvalidArgumentException("O numero é maior que o permitido [$format]."); |
| 201 | 201 | } |