@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | //get length of OID data |
75 | 75 | $len = self::getLength($data); |
76 | 76 | //get only a string with bytes belongs to OID |
77 | - $oidData = substr($data, 2 + $bytes, $len-($bytes)); |
|
77 | + $oidData = substr($data, 2 + $bytes, $len - ($bytes)); |
|
78 | 78 | //parse OID data many possibel formats and structures |
79 | 79 | $head = strlen($oidData) - strlen($xcv) - 2; |
80 | 80 | $ret = substr($oidData, -$head); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | if ($num == 0) { |
119 | 119 | $bun = 40 * $partes[$num]; |
120 | 120 | } elseif ($num == 1) { |
121 | - $bun += $partes[$num]; |
|
121 | + $bun += $partes[$num]; |
|
122 | 122 | $abBinary[] = $bun; |
123 | 123 | } else { |
124 | 124 | $abBinary = self::xBase128($abBinary, (integer) $partes[$num], true); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | { |
143 | 143 | $abc = $abIn; |
144 | 144 | if ($qIn > 127) { |
145 | - $abc = self::xBase128($abc, floor($qIn/128), false); |
|
145 | + $abc = self::xBase128($abc, floor($qIn / 128), false); |
|
146 | 146 | } |
147 | 147 | $qIn2 = $qIn % 128; |
148 | 148 | if ($flag) { |
@@ -181,7 +181,7 @@ |
||
181 | 181 | * @param array $abIn |
182 | 182 | * @param integer $qIn |
183 | 183 | * @param boolean $flag |
184 | - * @return array |
|
184 | + * @return integer[] |
|
185 | 185 | */ |
186 | 186 | protected static function xBase128($abIn, $qIn, $flag) |
187 | 187 | { |
@@ -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 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | switch ($soapver) { |
72 | 72 | case SOAP_1_1: |
73 | 73 | $parameters[] = "Content-Type: text/xml;charset=UTF-8;"; |
74 | - if(!empty($action)) $parameters[] = "SOAPAction: \"$action\""; |
|
74 | + if (!empty($action)) $parameters[] = "SOAPAction: \"$action\""; |
|
75 | 75 | $parameters[] = "Content-length: $msgSize"; |
76 | 76 | break; |
77 | 77 | case SOAP_1_2: |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | "Content-Type: application/soap+xml;charset=utf-8;", |
80 | 80 | "Content-length: $msgSize" |
81 | 81 | ]; |
82 | - if(!empty($action)) $parameter[0] .= "action=$action"; |
|
82 | + if (!empty($action)) $parameter[0] .= "action=$action"; |
|
83 | 83 | break; |
84 | 84 | default: |
85 | 85 | $parameters = [ |
86 | 86 | "Content-Type: application/soap+xml;charset=utf-8;", |
87 | 87 | "Content-length: $msgSize" |
88 | 88 | ]; |
89 | - if(!empty($action)) $parameter[0] .= "action=$action"; |
|
89 | + if (!empty($action)) $parameter[0] .= "action=$action"; |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 |
@@ -71,7 +71,9 @@ discard block |
||
71 | 71 | switch ($soapver) { |
72 | 72 | case SOAP_1_1: |
73 | 73 | $parameters[] = "Content-Type: text/xml;charset=UTF-8;"; |
74 | - if(!empty($action)) $parameters[] = "SOAPAction: \"$action\""; |
|
74 | + if(!empty($action)) { |
|
75 | + $parameters[] = "SOAPAction: \"$action\""; |
|
76 | + } |
|
75 | 77 | $parameters[] = "Content-length: $msgSize"; |
76 | 78 | break; |
77 | 79 | case SOAP_1_2: |
@@ -79,14 +81,18 @@ discard block |
||
79 | 81 | "Content-Type: application/soap+xml;charset=utf-8;", |
80 | 82 | "Content-length: $msgSize" |
81 | 83 | ]; |
82 | - if(!empty($action)) $parameter[0] .= "action=$action"; |
|
84 | + if(!empty($action)) { |
|
85 | + $parameter[0] .= "action=$action"; |
|
86 | + } |
|
83 | 87 | break; |
84 | 88 | default: |
85 | 89 | $parameters = [ |
86 | 90 | "Content-Type: application/soap+xml;charset=utf-8;", |
87 | 91 | "Content-length: $msgSize" |
88 | 92 | ]; |
89 | - if(!empty($action)) $parameter[0] .= "action=$action"; |
|
93 | + if(!empty($action)) { |
|
94 | + $parameter[0] .= "action=$action"; |
|
95 | + } |
|
90 | 96 | break; |
91 | 97 | } |
92 | 98 |