@@ -24,7 +24,7 @@ |
||
24 | 24 | ]); |
25 | 25 | $metadata->addPropertyConstraints('serie', [ |
26 | 26 | new Assert\NotBlank(), |
27 | - new Assert\Length([ 'max' => 4]), |
|
27 | + new Assert\Length(['max' => 4]), |
|
28 | 28 | ]); |
29 | 29 | $metadata->addPropertyConstraints('correlativo', [ |
30 | 30 | new Assert\NotBlank(), |
@@ -40,7 +40,7 @@ |
||
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 = ""; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ]); |
29 | 29 | $metadata->addPropertyConstraints('serie', [ |
30 | 30 | new Assert\NotBlank(), |
31 | - new Assert\Length([ 'max' => 4]), |
|
31 | + new Assert\Length(['max' => 4]), |
|
32 | 32 | ]); |
33 | 33 | $metadata->addPropertyConstraints('correlativo', [ |
34 | 34 | new Assert\NotBlank(), |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ]); |
68 | 68 | $metadata->addPropertyConstraints('desMotivo', [ |
69 | 69 | new Assert\NotBlank(), |
70 | - new Assert\Length([ 'max' => 250]), |
|
70 | + new Assert\Length(['max' => 250]), |
|
71 | 71 | ]); |
72 | 72 | $metadata->addPropertyConstraints('tipDocAfectado', [ |
73 | 73 | new Assert\NotBlank(), |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | ]); |
79 | 79 | $metadata->addPropertyConstraints('numDocfectado', [ |
80 | 80 | new Assert\NotBlank(), |
81 | - new Assert\Length([ 'max' => 13]), |
|
81 | + new Assert\Length(['max' => 13]), |
|
82 | 82 | ]); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | 'fileName' => $filename, |
35 | 35 | 'contentFile' => $content, |
36 | 36 | ]; |
37 | - $response = $client->__soapCall('sendBill', [ 'parameters' => $params ]); |
|
37 | + $response = $client->__soapCall('sendBill', ['parameters' => $params]); |
|
38 | 38 | return $response->applicationResponse; |
39 | 39 | // $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml'); |
40 | 40 | // if (!empty($entry)) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'fileName' => $filename, |
59 | 59 | 'contentFile' => $content, |
60 | 60 | ]; |
61 | - $response = $client->__soapCall('sendSummary', [ 'parameters' => $params ]); |
|
61 | + $response = $client->__soapCall('sendSummary', ['parameters' => $params]); |
|
62 | 62 | return $response->ticket; |
63 | 63 | // $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml'); |
64 | 64 | // if (!empty($entry)) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $params = [ |
82 | 82 | 'ticket' => $ticket, |
83 | 83 | ]; |
84 | - $response = $client->__soapCall('getStatus', [ 'parameters' => $params ]); |
|
84 | + $response = $client->__soapCall('getStatus', ['parameters' => $params]); |
|
85 | 85 | return $response->statusResponse; |
86 | 86 | // $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml'); |
87 | 87 | // if (!empty($entry)) { |
@@ -19,12 +19,21 @@ |
||
19 | 19 | const PRODUCCION = 'https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService'; |
20 | 20 | const WSDL_ENDPOINT = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'; |
21 | 21 | |
22 | + /** |
|
23 | + * @param string $user |
|
24 | + * @param string $password |
|
25 | + */ |
|
22 | 26 | public function __construct($user, $password) |
23 | 27 | { |
24 | 28 | parent::__construct($user, $password); |
25 | 29 | $this->setUrlWsdl(FeSunat::WSDL_ENDPOINT); |
26 | 30 | } |
27 | 31 | |
32 | + /** |
|
33 | + * @param string $content |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
28 | 37 | public function send($filename, $content) |
29 | 38 | { |
30 | 39 | $client = parent::getClient(); |
@@ -42,8 +42,7 @@ discard block |
||
42 | 42 | // echo $entry; |
43 | 43 | // } |
44 | 44 | |
45 | - } |
|
46 | - catch (\Exception $e) { |
|
45 | + } catch (\Exception $e) { |
|
47 | 46 | // $client->__getLastResponse() |
48 | 47 | return $e->getMessage(); |
49 | 48 | } |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | // echo $entry; |
67 | 66 | // } |
68 | 67 | |
69 | - } |
|
70 | - catch (\Exception $e) { |
|
68 | + } catch (\Exception $e) { |
|
71 | 69 | // $client->__getLastResponse() |
72 | 70 | return $e->getMessage(); |
73 | 71 | } |
@@ -89,8 +87,7 @@ discard block |
||
89 | 87 | // echo $entry; |
90 | 88 | // } |
91 | 89 | |
92 | - } |
|
93 | - catch (\SoapFault $fault) { |
|
90 | + } catch (\SoapFault $fault) { |
|
94 | 91 | // $client->__getLastResponse() |
95 | 92 | // $fault->faultstring; |
96 | 93 | return $fault->faultcode; |
@@ -101,21 +101,21 @@ discard block |
||
101 | 101 | $name = str_replace('\\', '/', $name); |
102 | 102 | $hexdtime = pack('V', $this->unix2DosTime($time)); |
103 | 103 | $frd = "\x50\x4b\x03\x04"; |
104 | - $frd .= "\x14\x00"; // ver needed to extract |
|
105 | - $frd .= "\x00\x00"; // gen purpose bit flag |
|
106 | - $frd .= "\x08\x00"; // compression method |
|
107 | - $frd .= $hexdtime; // last mod time and date |
|
104 | + $frd .= "\x14\x00"; // ver needed to extract |
|
105 | + $frd .= "\x00\x00"; // gen purpose bit flag |
|
106 | + $frd .= "\x08\x00"; // compression method |
|
107 | + $frd .= $hexdtime; // last mod time and date |
|
108 | 108 | // "local file header" segment |
109 | 109 | $unc_len = strlen($data); |
110 | 110 | $crc = crc32($data); |
111 | 111 | $zdata = gzcompress($data); |
112 | 112 | $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug |
113 | 113 | $c_len = strlen($zdata); |
114 | - $frd .= pack('V', $crc); // crc32 |
|
115 | - $frd .= pack('V', $c_len); // compressed filesize |
|
116 | - $frd .= pack('V', $unc_len); // uncompressed filesize |
|
117 | - $frd .= pack('v', strlen($name)); // length of filename |
|
118 | - $frd .= pack('v', 0); // extra field length |
|
114 | + $frd .= pack('V', $crc); // crc32 |
|
115 | + $frd .= pack('V', $c_len); // compressed filesize |
|
116 | + $frd .= pack('V', $unc_len); // uncompressed filesize |
|
117 | + $frd .= pack('v', strlen($name)); // length of filename |
|
118 | + $frd .= pack('v', 0); // extra field length |
|
119 | 119 | $frd .= $name; |
120 | 120 | // "file data" segment |
121 | 121 | $frd .= $zdata; |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | } |
126 | 126 | // now add to central directory record |
127 | 127 | $cdrec = "\x50\x4b\x01\x02"; |
128 | - $cdrec .= "\x00\x00"; // version made by |
|
129 | - $cdrec .= "\x14\x00"; // version needed to extract |
|
130 | - $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
131 | - $cdrec .= "\x08\x00"; // compression method |
|
132 | - $cdrec .= $hexdtime; // last mod time & date |
|
133 | - $cdrec .= pack('V', $crc); // crc32 |
|
134 | - $cdrec .= pack('V', $c_len); // compressed filesize |
|
135 | - $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
128 | + $cdrec .= "\x00\x00"; // version made by |
|
129 | + $cdrec .= "\x14\x00"; // version needed to extract |
|
130 | + $cdrec .= "\x00\x00"; // gen purpose bit flag |
|
131 | + $cdrec .= "\x08\x00"; // compression method |
|
132 | + $cdrec .= $hexdtime; // last mod time & date |
|
133 | + $cdrec .= pack('V', $crc); // crc32 |
|
134 | + $cdrec .= pack('V', $c_len); // compressed filesize |
|
135 | + $cdrec .= pack('V', $unc_len); // uncompressed filesize |
|
136 | 136 | $cdrec .= pack('v', strlen($name)); // length of filename |
137 | - $cdrec .= pack('v', 0); // extra field length |
|
138 | - $cdrec .= pack('v', 0); // file comment length |
|
139 | - $cdrec .= pack('v', 0); // disk number start |
|
140 | - $cdrec .= pack('v', 0); // internal file attributes |
|
141 | - $cdrec .= pack('V', 32); // external file attributes |
|
137 | + $cdrec .= pack('v', 0); // extra field length |
|
138 | + $cdrec .= pack('v', 0); // file comment length |
|
139 | + $cdrec .= pack('v', 0); // disk number start |
|
140 | + $cdrec .= pack('v', 0); // internal file attributes |
|
141 | + $cdrec .= pack('V', 32); // external file attributes |
|
142 | 142 | // - 'archive' bit set |
143 | 143 | $cdrec .= pack('V', $this->old_offset); // relative offset of local header |
144 | 144 | $this->old_offset += strlen($frd); |
@@ -158,21 +158,21 @@ discard block |
||
158 | 158 | public function file() |
159 | 159 | { |
160 | 160 | $ctrldir = implode('', $this->ctrl_dir); |
161 | - $header = $ctrldir. |
|
162 | - $this->eof_ctrl_dir. |
|
163 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries "on this disk" |
|
164 | - pack('v', sizeof($this->ctrl_dir)). //total #of entries overall |
|
165 | - pack('V', strlen($ctrldir)). //size of central dir |
|
166 | - pack('V', $this->old_offset). //offset to start of central dir |
|
167 | - "\x00\x00"; //.zip file comment length |
|
161 | + $header = $ctrldir . |
|
162 | + $this->eof_ctrl_dir . |
|
163 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries "on this disk" |
|
164 | + pack('v', sizeof($this->ctrl_dir)) . //total #of entries overall |
|
165 | + pack('V', strlen($ctrldir)) . //size of central dir |
|
166 | + pack('V', $this->old_offset) . //offset to start of central dir |
|
167 | + "\x00\x00"; //.zip file comment length |
|
168 | 168 | if ($this->doWrite) { // Send central directory & end ctrl dir to STDOUT |
169 | - return ''; // Return empty string |
|
169 | + return ''; // Return empty string |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Return entire ZIP archive as string |
173 | 173 | $data = implode('', $this->datasec); |
174 | 174 | |
175 | - return $data.$header; |
|
175 | + return $data . $header; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | // end of the 'file()' method |