@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function decompress($zipContent, $fileToExtract) |
| 42 | 42 | { |
| 43 | - $temp = tempnam(sys_get_temp_dir(),time() . '.zip'); |
|
| 43 | + $temp = tempnam(sys_get_temp_dir(), time() . '.zip'); |
|
| 44 | 44 | file_put_contents($temp, $zipContent); |
| 45 | 45 | $zip = new ZipArchive; |
| 46 | 46 | $output = ""; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function decompressLastFile($zipContent) |
| 63 | 63 | { |
| 64 | - $temp = tempnam(sys_get_temp_dir(),time() . '.zip'); |
|
| 64 | + $temp = tempnam(sys_get_temp_dir(), time() . '.zip'); |
|
| 65 | 65 | file_put_contents($temp, $zipContent); |
| 66 | 66 | $zip = new ZipArchive; |
| 67 | 67 | $output = ""; |
@@ -69,9 +69,9 @@ |
||
| 69 | 69 | $obj = $resp[0]; |
| 70 | 70 | |
| 71 | 71 | $cdr = new CdrResponse(); |
| 72 | - $cdr->setId($this->getValueByName($obj,'ReferenceID')) |
|
| 73 | - ->setCode($this->getValueByName($obj,'ResponseCode')) |
|
| 74 | - ->setDescription($this->getValueByName($obj,'Description')); |
|
| 72 | + $cdr->setId($this->getValueByName($obj, 'ReferenceID')) |
|
| 73 | + ->setCode($this->getValueByName($obj, 'ResponseCode')) |
|
| 74 | + ->setDescription($this->getValueByName($obj, 'Description')); |
|
| 75 | 75 | |
| 76 | 76 | return $cdr; |
| 77 | 77 | } |
@@ -80,21 +80,21 @@ discard block |
||
| 80 | 80 | $name = str_replace('\\', '/', $name); |
| 81 | 81 | $hexdtime = pack('V', $this->unix2DosTime($time)); |
| 82 | 82 | $frd = "\x50\x4b\x03\x04"; |
| 83 | - $frd .= "\x14\x00"; // ver needed to extract |
|
| 84 | - $frd .= "\x00\x00"; // gen purpose bit flag |
|
| 85 | - $frd .= "\x08\x00"; // compression method |
|
| 86 | - $frd .= $hexdtime; // last mod time and date |
|
| 83 | + $frd .= "\x14\x00"; // ver needed to extract |
|
| 84 | + $frd .= "\x00\x00"; // gen purpose bit flag |
|
| 85 | + $frd .= "\x08\x00"; // compression method |
|
| 86 | + $frd .= $hexdtime; // last mod time and date |
|
| 87 | 87 | // "local file header" segment |
| 88 | 88 | $unc_len = strlen($data); |
| 89 | 89 | $crc = crc32($data); |
| 90 | 90 | $zdata = gzcompress($data); |
| 91 | 91 | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
| 92 | 92 | $c_len = strlen($zdata); |
| 93 | - $frd .= pack('V', $crc); // crc32 |
|
| 94 | - $frd .= pack('V', $c_len); // compressed filesize |
|
| 95 | - $frd .= pack('V', $unc_len); // uncompressed filesize |
|
| 96 | - $frd .= pack('v', strlen($name)); // length of filename |
|
| 97 | - $frd .= pack('v', 0); // extra field length |
|
| 93 | + $frd .= pack('V', $crc); // crc32 |
|
| 94 | + $frd .= pack('V', $c_len); // compressed filesize |
|
| 95 | + $frd .= pack('V', $unc_len); // uncompressed filesize |
|
| 96 | + $frd .= pack('v', strlen($name)); // length of filename |
|
| 97 | + $frd .= pack('v', 0); // extra field length |
|
| 98 | 98 | $frd .= $name; |
| 99 | 99 | // "file data" segment |
| 100 | 100 | $frd .= $zdata; |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | $this->datasec[] = $frd; |
| 103 | 103 | // now add to central directory record |
| 104 | 104 | $cdrec = "\x50\x4b\x01\x02"; |
| 105 | - $cdrec .= "\x00\x00"; // version made by |
|
| 106 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
| 107 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 108 | - $cdrec .= "\x08\x00"; // compression method |
|
| 109 | - $cdrec .= $hexdtime; // last mod time & date |
|
| 110 | - $cdrec .= pack('V', $crc); // crc32 |
|
| 111 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 112 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 105 | + $cdrec .= "\x00\x00"; // version made by |
|
| 106 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
| 107 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
| 108 | + $cdrec .= "\x08\x00"; // compression method |
|
| 109 | + $cdrec .= $hexdtime; // last mod time & date |
|
| 110 | + $cdrec .= pack('V', $crc); // crc32 |
|
| 111 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
| 112 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
| 113 | 113 | $cdrec .= pack('v', strlen($name)); // length of filename |
| 114 | - $cdrec .= pack('v', 0); // extra field length |
|
| 115 | - $cdrec .= pack('v', 0); // file comment length |
|
| 116 | - $cdrec .= pack('v', 0); // disk number start |
|
| 117 | - $cdrec .= pack('v', 0); // internal file attributes |
|
| 118 | - $cdrec .= pack('V', 32); // external file attributes |
|
| 114 | + $cdrec .= pack('v', 0); // extra field length |
|
| 115 | + $cdrec .= pack('v', 0); // file comment length |
|
| 116 | + $cdrec .= pack('v', 0); // disk number start |
|
| 117 | + $cdrec .= pack('v', 0); // internal file attributes |
|
| 118 | + $cdrec .= pack('V', 32); // external file attributes |
|
| 119 | 119 | // - 'archive' bit set |
| 120 | 120 | $cdrec .= pack('V', $this->old_offset); // relative offset of local header |
| 121 | 121 | $this->old_offset += strlen($frd); |
@@ -135,18 +135,18 @@ discard block |
||
| 135 | 135 | public function file() |
| 136 | 136 | { |
| 137 | 137 | $ctrldir = implode('', $this->ctrl_dir); |
| 138 | - $header = $ctrldir. |
|
| 139 | - $this->eof_ctrl_dir. |
|
| 140 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries "on this disk" |
|
| 141 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries overall |
|
| 142 | - pack('V', strlen($ctrldir)). //size of central dir |
|
| 143 | - pack('V', $this->old_offset). //offset to start of central dir |
|
| 144 | - "\x00\x00"; //.zip file comment length |
|
| 138 | + $header = $ctrldir . |
|
| 139 | + $this->eof_ctrl_dir . |
|
| 140 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries "on this disk" |
|
| 141 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries overall |
|
| 142 | + pack('V', strlen($ctrldir)) . //size of central dir |
|
| 143 | + pack('V', $this->old_offset) . //offset to start of central dir |
|
| 144 | + "\x00\x00"; //.zip file comment length |
|
| 145 | 145 | |
| 146 | 146 | // Return entire ZIP archive as string |
| 147 | 147 | $data = implode('', $this->datasec); |
| 148 | 148 | |
| 149 | - return $data.$header; |
|
| 149 | + return $data . $header; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | // end of the 'file()' method |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * FACTURACION SERVICES. |
| 19 | 19 | */ |
| 20 | 20 | const FE_BETA = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService'; |
| 21 | - const FE_HOMOLOGACION = 'https://www.sunat.gob.pe/ol-ti-itcpgem-sqa/billService'; |
|
| 21 | + const FE_HOMOLOGACION = 'https://www.sunat.gob.pe/ol-ti-itcpgem-sqa/billService'; |
|
| 22 | 22 | const FE_PRODUCCION = 'https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService'; |
| 23 | 23 | const WSDL_ENDPOINT = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'; |
| 24 | 24 | |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | $result |
| 37 | 37 | ->setTicket($response->ticket) |
| 38 | 38 | ->setSuccess(true); |
| 39 | - } |
|
| 40 | - catch (\SoapFault $e) { |
|
| 39 | + } catch (\SoapFault $e) { |
|
| 41 | 40 | $result->setError($this->getErrorFromFault($e)); |
| 42 | 41 | } |
| 43 | 42 | return $result; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | 'fileName' => $filename, |
| 33 | 33 | 'contentFile' => $content, |
| 34 | 34 | ]; |
| 35 | - $response = $client->call('sendSummary', [ 'parameters' => $params ]); |
|
| 35 | + $response = $client->call('sendSummary', ['parameters' => $params]); |
|
| 36 | 36 | $result |
| 37 | 37 | ->setTicket($response->ticket) |
| 38 | 38 | ->setSuccess(true); |
@@ -39,8 +39,7 @@ |
||
| 39 | 39 | ->setCdrResponse($this->extractResponse($cdrZip)) |
| 40 | 40 | ->setCdrZip($cdrZip) |
| 41 | 41 | ->setSuccess(true); |
| 42 | - } |
|
| 43 | - catch (\SoapFault $e) { |
|
| 42 | + } catch (\SoapFault $e) { |
|
| 44 | 43 | $result->setError($this->getErrorFromFault($e)); |
| 45 | 44 | } |
| 46 | 45 | |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | 'fileName' => $filename, |
| 33 | 33 | 'contentFile' => $content, |
| 34 | 34 | ]; |
| 35 | - $response = $client->call('sendBill', [ 'parameters' => $params ]); |
|
| 35 | + $response = $client->call('sendBill', ['parameters' => $params]); |
|
| 36 | 36 | $cdrZip = $response->applicationResponse; |
| 37 | 37 | $result |
| 38 | 38 | ->setCdrResponse($this->extractResponse($cdrZip)) |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | public function __construct($wsdl = '', $parameters = []) |
| 27 | 27 | { |
| 28 | 28 | if (empty($wsdl)) { |
| 29 | - $wsdl = __DIR__.'/../../Resources/wsdl/billService.wsdl'; |
|
| 29 | + $wsdl = __DIR__ . '/../../Resources/wsdl/billService.wsdl'; |
|
| 30 | 30 | } |
| 31 | 31 | $this->client = new \SoapClient($wsdl, $parameters); |
| 32 | 32 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $params = [ |
| 31 | 31 | 'ticket' => $ticket, |
| 32 | 32 | ]; |
| 33 | - $response = $client->call('getStatus', [ 'parameters' => $params ]); |
|
| 33 | + $response = $client->call('getStatus', ['parameters' => $params]); |
|
| 34 | 34 | $status = $response->status; |
| 35 | 35 | $cdrZip = $status->content; |
| 36 | 36 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | 'serieComprobante' => $serie, |
| 67 | 67 | 'numeroComprobante' => $numero, |
| 68 | 68 | ]; |
| 69 | - $response = $client->call('getStatusCdr', [ 'parameters' => $params ]); |
|
| 70 | - $statusCdr =$response->statusCdr; |
|
| 69 | + $response = $client->call('getStatusCdr', ['parameters' => $params]); |
|
| 70 | + $statusCdr = $response->statusCdr; |
|
| 71 | 71 | |
| 72 | 72 | $result->setCode($statusCdr->statusCode) |
| 73 | 73 | ->setMessage($statusCdr->statusMessage) |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | ->setCdrResponse($this->extractResponse($cdrZip)) |
| 40 | 40 | ->setCdrZip($cdrZip) |
| 41 | 41 | ->setSuccess(true); |
| 42 | - } |
|
| 43 | - catch (\SoapFault $e) { |
|
| 42 | + } catch (\SoapFault $e) { |
|
| 44 | 43 | $result->setError($this->getErrorFromFault($e)); |
| 45 | 44 | } |
| 46 | 45 | |
@@ -77,8 +76,7 @@ discard block |
||
| 77 | 76 | if ($statusCdr->content) { |
| 78 | 77 | $result->setCdrResponse($this->extractResponse($statusCdr->content)); |
| 79 | 78 | } |
| 80 | - } |
|
| 81 | - catch (\SoapFault $e) { |
|
| 79 | + } catch (\SoapFault $e) { |
|
| 82 | 80 | $result->setError($this->getErrorFromFault($e)); |
| 83 | 81 | } |
| 84 | 82 | |
@@ -50,7 +50,7 @@ |
||
| 50 | 50 | private function initTwig($options) |
| 51 | 51 | { |
| 52 | 52 | $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../Templates'); |
| 53 | - $numFilter = new \Twig_SimpleFilter('n_format', function ($number, $decimals = 2) { |
|
| 53 | + $numFilter = new \Twig_SimpleFilter('n_format', function($number, $decimals = 2) { |
|
| 54 | 54 | return number_format($number, $decimals, '.', ''); |
| 55 | 55 | }); |
| 56 | 56 | $twig = new \Twig_Environment($loader, $options); |