@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | class Signer |
| 33 | 33 | { |
| 34 | - private static $canonical = [false,false,null,null]; |
|
| 34 | + private static $canonical = [false, false, null, null]; |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Make Signature tag |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $tagname = '', |
| 51 | 51 | $mark = 'Id', |
| 52 | 52 | $algorithm = OPENSSL_ALGO_SHA1, |
| 53 | - $canonical = [false,false,null,null], |
|
| 53 | + $canonical = [false, false, null, null], |
|
| 54 | 54 | $rootname = '' |
| 55 | 55 | ) { |
| 56 | 56 | //$content = Strings::clearXmlString($content, true); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | if (empty($node) || empty($root)) { |
| 70 | 70 | throw SignerException::tagNotFound($tagname . ' ' . $rootname); |
| 71 | 71 | } |
| 72 | - if (! self::existsSignature($dom)) { |
|
| 72 | + if (!self::existsSignature($dom)) { |
|
| 73 | 73 | $dom = self::createSignature( |
| 74 | 74 | $certificate, |
| 75 | 75 | $dom, |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | DOMElement $node, |
| 134 | 134 | $mark, |
| 135 | 135 | $algorithm = OPENSSL_ALGO_SHA1, |
| 136 | - $canonical = [false,false,null,null] |
|
| 136 | + $canonical = [false, false, null, null] |
|
| 137 | 137 | ) { |
| 138 | 138 | $nsDSIG = 'http://www.w3.org/2000/09/xmldsig#'; |
| 139 | 139 | $nsCannonMethod = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $nsSignatureMethod = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256'; |
| 146 | 146 | $nsDigestMethod = 'http://www.w3.org/2001/04/xmlenc#sha256'; |
| 147 | 147 | } |
| 148 | - $nsTransformMethod1 ='http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 148 | + $nsTransformMethod1 = 'http://www.w3.org/2000/09/xmldsig#enveloped-signature'; |
|
| 149 | 149 | $nsTransformMethod2 = 'http://www.w3.org/TR/2001/REC-xml-c14n-20010315'; |
| 150 | 150 | $idSigned = trim($node->getAttribute($mark)); |
| 151 | 151 | $digestValue = self::makeDigest($node, $digestAlgorithm, $canonical); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | throw SignnerException::tagNotFound($tagname); |
| 251 | 251 | } |
| 252 | 252 | $signature = $dom->getElementsByTagName('Signature')->item(0); |
| 253 | - if (! empty($signature)) { |
|
| 253 | + if (!empty($signature)) { |
|
| 254 | 254 | $clone = $signature->cloneNode(true); |
| 255 | 255 | } else { |
| 256 | 256 | $signature = $dom->getElementsByTagName('Signature')->item(0); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * @param array $canonical |
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | - private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false,false,null,null]) |
|
| 282 | + private static function makeDigest(DOMElement $node, $algorithm, $canonical = [false, false, null, null]) |
|
| 283 | 283 | { |
| 284 | 284 | $dados = $node->C14N(true, false, null, null); |
| 285 | 285 | //calcular o hash dos dados |
@@ -39,10 +39,10 @@ |
||
| 39 | 39 | $dom->formatOutput = false; |
| 40 | 40 | $dom->loadXML($xml, LIBXML_NOBLANKS | LIBXML_NOEMPTYTAG); |
| 41 | 41 | libxml_clear_errors(); |
| 42 | - if (! $dom->schemaValidate($xsd)) { |
|
| 42 | + if (!$dom->schemaValidate($xsd)) { |
|
| 43 | 43 | $msg = ''; |
| 44 | 44 | foreach (libxml_get_errors() as $error) { |
| 45 | - $msg .= $error->message."\n"; |
|
| 45 | + $msg .= $error->message . "\n"; |
|
| 46 | 46 | } |
| 47 | 47 | throw new RuntimeException($msg); |
| 48 | 48 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | //get length of OID data |
| 79 | 79 | $len = self::getLength((string) $data); |
| 80 | 80 | //get only a string with bytes belongs to OID |
| 81 | - $oidData = substr($data, 2 + $bytes, $len-($bytes)); |
|
| 81 | + $oidData = substr($data, 2 + $bytes, $len - ($bytes)); |
|
| 82 | 82 | //parse OID data many possibel formats and structures |
| 83 | 83 | $head = strlen($oidData) - strlen($xcv) - 2; |
| 84 | 84 | $ret = substr($oidData, -$head); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if ($num == 0) { |
| 125 | 125 | $bun = 40 * $partes[$num]; |
| 126 | 126 | } elseif ($num == 1) { |
| 127 | - $bun += $partes[$num]; |
|
| 127 | + $bun += $partes[$num]; |
|
| 128 | 128 | $abBinary[] = $bun; |
| 129 | 129 | } else { |
| 130 | 130 | $abBinary = self::xBase128((array) $abBinary, (integer) $partes[$num], true); |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | { |
| 149 | 149 | $abc = $abIn; |
| 150 | 150 | if ($qIn > 127) { |
| 151 | - $abc = $this->xBase128($abc, floor($qIn/128), false); |
|
| 151 | + $abc = $this->xBase128($abc, floor($qIn / 128), false); |
|
| 152 | 152 | } |
| 153 | 153 | $qIn2 = $qIn % 128; |
| 154 | 154 | if ($flag) { |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | private static function loadOids() |
| 53 | 53 | { |
| 54 | - $json = file_get_contents(__DIR__ .'/oids.json'); |
|
| 54 | + $json = file_get_contents(__DIR__ . '/oids.json'); |
|
| 55 | 55 | self::$oidsTable = (array) json_decode($json, true); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -93,8 +93,7 @@ |
||
| 93 | 93 | $detail = openssl_x509_parse($resource, false); |
| 94 | 94 | $this->commonName = $detail['subject']['commonName']; |
| 95 | 95 | $this->emailAddress = !empty($detail['subject']['emailAddress']) ? |
| 96 | - $detail['subject']['emailAddress'] : |
|
| 97 | - ''; |
|
| 96 | + $detail['subject']['emailAddress'] : ''; |
|
| 98 | 97 | $this->cspName = $detail['issuer']['organizationalUnitName']; |
| 99 | 98 | $this->serialNumber = $detail['serialNumber']; |
| 100 | 99 | $this->validFrom = \DateTime::createFromFormat('ymdHis\Z', $detail['validFrom']); |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | public static function replaceSpecialsChars($string) |
| 24 | 24 | { |
| 25 | 25 | $string = trim($string); |
| 26 | - $aFind = ['&','á','à','ã','â','é','ê','í','ó','ô','õ','ú','ü', |
|
| 27 | - 'ç','Á','À','Ã','Â','É','Ê','Í','Ó','Ô','Õ','Ú','Ü','Ç']; |
|
| 28 | - $aSubs = ['e','a','a','a','a','e','e','i','o','o','o','u','u', |
|
| 29 | - 'c','A','A','A','A','E','E','I','O','O','O','U','U','C']; |
|
| 26 | + $aFind = ['&', 'á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü', |
|
| 27 | + 'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç']; |
|
| 28 | + $aSubs = ['e', 'a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u', |
|
| 29 | + 'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C']; |
|
| 30 | 30 | $newstr = str_replace($aFind, $aSubs, $string); |
| 31 | 31 | $newstr = preg_replace("/[^a-zA-Z0-9 @,-.;:\/]/", "", $newstr); |
| 32 | 32 | return $newstr; |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | public static function clearProtocoledXML($string) |
| 85 | 85 | { |
| 86 | 86 | $procXML = self::clearXmlString($string); |
| 87 | - $aApp = array('nfe','cte','mdfe'); |
|
| 87 | + $aApp = array('nfe', 'cte', 'mdfe'); |
|
| 88 | 88 | foreach ($aApp as $app) { |
| 89 | 89 | $procXML = str_replace( |
| 90 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 91 | - 'xmlns="http://www.portalfiscal.inf.br/'.$app.'"', |
|
| 90 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '" xmlns="http://www.w3.org/2000/09/xmldsig#"', |
|
| 91 | + 'xmlns="http://www.portalfiscal.inf.br/' . $app . '"', |
|
| 92 | 92 | $procXML |
| 93 | 93 | ); |
| 94 | 94 | } |
@@ -250,9 +250,9 @@ |
||
| 250 | 250 | ); |
| 251 | 251 | } |
| 252 | 252 | $this->certsdir = $this->certificate->getCnpj() . '/certs/'; |
| 253 | - $this->prifile = $this->certsdir. Strings::randomString(10).'.pem'; |
|
| 254 | - $this->pubfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
| 255 | - $this->certfile = $this->certsdir . Strings::randomString(10).'.pem'; |
|
| 253 | + $this->prifile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 254 | + $this->pubfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 255 | + $this->certfile = $this->certsdir . Strings::randomString(10) . '.pem'; |
|
| 256 | 256 | $ret = true; |
| 257 | 257 | $ret &= $this->filesystem->put( |
| 258 | 258 | $this->prifile, |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function __doRequest($request, $location, $action, $version, $oneWay = 0) |
| 32 | 32 | { |
| 33 | - $search = [":ns1","ns1:","\n","\r"]; |
|
| 33 | + $search = [":ns1", "ns1:", "\n", "\r"]; |
|
| 34 | 34 | return parent::__doRequest( |
| 35 | 35 | str_replace($search, '', $request), |
| 36 | 36 | $location, |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | { |
| 23 | 23 | public static function info($code) |
| 24 | 24 | { |
| 25 | - $codes = (array) json_decode(file_get_contents(__DIR__.'/httpcodes.json'), true); |
|
| 25 | + $codes = (array) json_decode(file_get_contents(__DIR__ . '/httpcodes.json'), true); |
|
| 26 | 26 | if (array_key_exists($code, $codes)) { |
| 27 | 27 | return $codes[$code]; |
| 28 | 28 | } |