@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * @param int $codigo Código del impuesto |
54 | 54 | * @return string A: adicional, R: retención y =false no se pudo determinar. |
55 | 55 | */ |
56 | - public function getTipo(int $codigo): string|false |
|
56 | + public function getTipo(int $codigo): string | false |
|
57 | 57 | { |
58 | 58 | $tipo = $this->dataProvider->getValue( |
59 | 59 | 'impuestos_adicionales_retenciones', |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $codigo, |
77 | 77 | false |
78 | 78 | ); |
79 | - return $glosa['glosa'] ?? 'Impto. cód. ' . $codigo; |
|
79 | + return $glosa['glosa'] ?? 'Impto. cód. '.$codigo; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param int $codigo Código del impuesto |
86 | 86 | * @return float|false Tasa del impuesto o =false si no se pudo determinar. |
87 | 87 | */ |
88 | - public function getTasa(int $codigo): float|false |
|
88 | + public function getTasa(int $codigo): float | false |
|
89 | 89 | { |
90 | 90 | $tasa = $this->dataProvider->getValue( |
91 | 91 | 'impuestos_adicionales_retenciones', |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | $retenido = 0.0; |
108 | 108 | foreach ($OtrosImp as $Imp) { |
109 | - if ($this->getTipo((int)$Imp['CodImp']) === 'R') { |
|
109 | + if ($this->getTipo((int)$Imp['CodImp'])==='R') { |
|
110 | 110 | $retenido += (float)$Imp['MntImp']; |
111 | 111 | } |
112 | 112 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param string $tag Tag de la tabla. |
60 | 60 | * @return string|false Glosa del campo o false si no existe. |
61 | 61 | */ |
62 | - public function getGlosa(string $tag): string|false |
|
62 | + public function getGlosa(string $tag): string | false |
|
63 | 63 | { |
64 | 64 | try { |
65 | 65 | $data = $this->dataProvider->getData('aduana'); |
@@ -81,31 +81,31 @@ discard block |
||
81 | 81 | $glosaData = $this->dataProvider->getData('aduana'); |
82 | 82 | |
83 | 83 | if (!isset($glosaData[$tag])) { |
84 | - return (string) $codigo; |
|
84 | + return (string)$codigo; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $datosFile = $glosaData[$tag]['datos'] ?? null; |
88 | 88 | |
89 | 89 | if (!$datosFile) { |
90 | - return (string) $codigo; |
|
90 | + return (string)$codigo; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $valuesData = $this->dataProvider->getData($datosFile); |
94 | 94 | |
95 | - if ($tag === 'TipoBultos') { |
|
95 | + if ($tag==='TipoBultos') { |
|
96 | 96 | $valor = $valuesData[$codigo['CodTpoBultos']] ?? $codigo['CodTpoBultos']; |
97 | - $valor = $codigo['CantBultos'] . ' ' . $valor; |
|
97 | + $valor = $codigo['CantBultos'].' '.$valor; |
|
98 | 98 | |
99 | 99 | if (!empty($codigo['IdContainer'])) { |
100 | - $valor .= ' (' . $codigo['IdContainer'] . ' / ' . $codigo['Sello'] . ' / ' . $codigo['EmisorSello'] . ')'; |
|
100 | + $valor .= ' ('.$codigo['IdContainer'].' / '.$codigo['Sello'].' / '.$codigo['EmisorSello'].')'; |
|
101 | 101 | } elseif (!empty($codigo['Marcas'])) { |
102 | - $valor .= ' (' . $codigo['Marcas'] . ')'; |
|
102 | + $valor .= ' ('.$codigo['Marcas'].')'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $valor; |
106 | 106 | } |
107 | 107 | |
108 | - return $valuesData[$codigo] ?? (string) $codigo; |
|
108 | + return $valuesData[$codigo] ?? (string)$codigo; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param string $valor Valor a buscar. |
116 | 116 | * @return int|string Código correspondiente o el valor si no se encuentra. |
117 | 117 | */ |
118 | - public function getCodigo(string $tag, string $valor): int|string |
|
118 | + public function getCodigo(string $tag, string $valor): int | string |
|
119 | 119 | { |
120 | 120 | $glosaData = $this->dataProvider->getData('aduana'); |
121 | 121 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public function getNacionalidad($codigo): string |
156 | 156 | { |
157 | 157 | $nacionalidades = $this->getNacionalidades(); |
158 | - return $nacionalidades[$codigo] ?? (string) $codigo; |
|
158 | + return $nacionalidades[$codigo] ?? (string)$codigo; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -80,6 +80,6 @@ |
||
80 | 80 | return $direccionRegional ?? $comuna; |
81 | 81 | } |
82 | 82 | |
83 | - return 'SUC ' . $comuna; |
|
83 | + return 'SUC '.$comuna; |
|
84 | 84 | } |
85 | 85 | } |
@@ -33,25 +33,25 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * Ubicación base, es la ruta donde está la biblioteca. |
35 | 35 | */ |
36 | - private const BASE_PATH = __DIR__ . '/../..'; |
|
36 | + private const BASE_PATH = __DIR__.'/../..'; |
|
37 | 37 | |
38 | 38 | // Directorios base de la biblioteca. |
39 | 39 | //private const CONFIG_PATH = self::BASE_PATH . '/config'; |
40 | 40 | //private const DOCS_PATH = self::BASE_PATH . '/docs'; |
41 | - private const RESOURCES_PATH = self::BASE_PATH . '/resources'; |
|
41 | + private const RESOURCES_PATH = self::BASE_PATH.'/resources'; |
|
42 | 42 | //private const SRC_PATH = self::BASE_PATH . '/src'; |
43 | - private const TESTS_PATH = self::BASE_PATH . '/tests'; |
|
44 | - private const VAR_PATH = self::BASE_PATH . '/var'; |
|
43 | + private const TESTS_PATH = self::BASE_PATH.'/tests'; |
|
44 | + private const VAR_PATH = self::BASE_PATH.'/var'; |
|
45 | 45 | //private const VENDOR_PATH = self::BASE_PATH . '/vendor'; |
46 | 46 | |
47 | 47 | // Directorios de recursos. |
48 | - private const CERTIFICATES_PATH = self::RESOURCES_PATH . '/certificates'; |
|
49 | - private const DATA_PATH = self::RESOURCES_PATH . '/data'; |
|
50 | - private const SCHEMAS_PATH = self::RESOURCES_PATH . '/schemas'; |
|
51 | - private const WSDL_PATH = self::RESOURCES_PATH . '/wsdl'; |
|
48 | + private const CERTIFICATES_PATH = self::RESOURCES_PATH.'/certificates'; |
|
49 | + private const DATA_PATH = self::RESOURCES_PATH.'/data'; |
|
50 | + private const SCHEMAS_PATH = self::RESOURCES_PATH.'/schemas'; |
|
51 | + private const WSDL_PATH = self::RESOURCES_PATH.'/wsdl'; |
|
52 | 52 | |
53 | 53 | // Directorio de caché. |
54 | - private const CACHE_PATH = self::VAR_PATH . '/cache'; |
|
54 | + private const CACHE_PATH = self::VAR_PATH.'/cache'; |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Obtiene la ruta completa del directorio de certificados o de un |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public static function getCertificatesPath(?string $filename = null): ?string |
64 | 64 | { |
65 | - if ($filename === null) { |
|
65 | + if ($filename===null) { |
|
66 | 66 | return realpath(self::CERTIFICATES_PATH); |
67 | 67 | } |
68 | 68 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function getSchemasPath(?string $filename = null): ?string |
93 | 93 | { |
94 | - if ($filename === null) { |
|
94 | + if ($filename===null) { |
|
95 | 95 | return realpath(self::SCHEMAS_PATH); |
96 | 96 | } |
97 | 97 |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | /** |
122 | 122 | * {@inheritdoc} |
123 | 123 | */ |
124 | - public function getValue(string $key, string|int $code, mixed $default = null): mixed |
|
124 | + public function getValue(string $key, string | int $code, mixed $default = null): mixed |
|
125 | 125 | { |
126 | 126 | $data = $this->getData($key); |
127 | 127 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | // Filtrar los datos del repositorio. |
148 | - return array_filter($data, function ($row, $code) use ($filters) { |
|
148 | + return array_filter($data, function($row, $code) use ($filters) { |
|
149 | 149 | // Recorrer los filtros e ir descartando lo que no coincida. |
150 | 150 | foreach ($filters as $filter => $values) { |
151 | 151 | // El filtro solicitado es por ID o código. |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $filepath = PathManager::getDataPath($key); |
189 | 189 | } |
190 | 190 | |
191 | - if ($filepath === null) { |
|
191 | + if ($filepath===null) { |
|
192 | 192 | throw new LogicException(sprintf( |
193 | 193 | 'El archivo de datos para la clave %s no existe.', |
194 | 194 | $key |
@@ -99,7 +99,7 @@ |
||
99 | 99 | */ |
100 | 100 | public function getValue( |
101 | 101 | string $key, |
102 | - string|int $code, |
|
102 | + string | int $code, |
|
103 | 103 | mixed $default = null |
104 | 104 | ): mixed; |
105 | 105 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string $file Ruta hacia el fichero. |
56 | 56 | * @return string|false Mimetype del fichero o false si no se pudo determinar. |
57 | 57 | */ |
58 | - public static function mimetype(string $file): string|false |
|
58 | + public static function mimetype(string $file): string | false |
|
59 | 59 | { |
60 | 60 | if (!file_exists($file)) { |
61 | 61 | return false; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | )); |
87 | 87 | } |
88 | 88 | |
89 | - $zipFilePath = $file . '.zip'; |
|
89 | + $zipFilePath = $file.'.zip'; |
|
90 | 90 | |
91 | 91 | self::zip($file, $zipFilePath); |
92 | 92 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ); |
140 | 140 | foreach ($finder as $foundFile) { |
141 | 141 | if (!$foundFile->isDir()) { |
142 | - $localName = str_replace($file . DIRECTORY_SEPARATOR, '', $foundFile->getPathname()); |
|
142 | + $localName = str_replace($file.DIRECTORY_SEPARATOR, '', $foundFile->getPathname()); |
|
143 | 143 | $zip->addFileFromPath($localName, $foundFile->getPathname()); |
144 | 144 | } |
145 | 145 | } |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | |
171 | 171 | $mimetype = self::mimetype($file); |
172 | 172 | if ($mimetype) { |
173 | - header('Content-Type: ' . $mimetype); |
|
173 | + header('Content-Type: '.$mimetype); |
|
174 | 174 | } |
175 | 175 | |
176 | - header('Content-Disposition: attachment; filename="' . basename($file) . '"'); |
|
177 | - header('Content-Length: ' . filesize($file)); |
|
176 | + header('Content-Disposition: attachment; filename="'.basename($file).'"'); |
|
177 | + header('Content-Length: '.filesize($file)); |
|
178 | 178 | header('Pragma: no-cache'); |
179 | 179 | header('Expires: 0'); |
180 | 180 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $dv = strtoupper(substr($rut, -1)); |
63 | 63 | $rut = substr($rut, 0, -1); |
64 | 64 | |
65 | - return [(int) $rut, $dv]; |
|
65 | + return [(int)$rut, $dv]; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param string|int $rut |
75 | 75 | * @return string |
76 | 76 | */ |
77 | - public static function format(string|int $rut): string |
|
77 | + public static function format(string | int $rut): string |
|
78 | 78 | { |
79 | 79 | // Si es un string, se espera que venga con DV, el guión es opcional. |
80 | 80 | if (is_string($rut)) { |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * @param string|integer $rut |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public static function formatFull(string|int $rut): string |
|
94 | + public static function formatFull(string | int $rut): string |
|
95 | 95 | { |
96 | 96 | $rut = self::format($rut); |
97 | 97 | [$rut, $dv] = self::toArray($rut); |
98 | 98 | |
99 | - return self::addThousandsSeparator($rut) . '-' . $dv; |
|
99 | + return self::addThousandsSeparator($rut).'-'.$dv; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | public static function calculateDv(int $rut): string |
109 | 109 | { |
110 | 110 | $s = 1; |
111 | - for ($m = 0; $rut != 0; $rut /= 10) { |
|
112 | - $rut = (int) $rut; |
|
113 | - $s = ($s + $rut % 10 * (9 - $m++ % 6)) % 11; |
|
111 | + for ($m = 0; $rut!=0; $rut /= 10) { |
|
112 | + $rut = (int)$rut; |
|
113 | + $s = ($s+$rut % 10 * (9-$m++ % 6)) % 11; |
|
114 | 114 | } |
115 | - return strtoupper(chr($s ? $s + 47 : 75)); |
|
115 | + return strtoupper(chr($s ? $s+47 : 75)); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | [$rut, $dv] = self::toArray($rut); |
129 | 129 | |
130 | 130 | // Validar mínimo del RUT. |
131 | - if ($rut < self::RUT_MIN) { |
|
131 | + if ($rut<self::RUT_MIN) { |
|
132 | 132 | throw new UnexpectedValueException(sprintf( |
133 | 133 | 'El RUT no puede ser menor a %s y se encontró el valor %s.', |
134 | 134 | self::addThousandsSeparator(self::RUT_MIN), |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | // Validar máximo del RUT. |
140 | - if ($rut > self::RUT_MAX) { |
|
140 | + if ($rut>self::RUT_MAX) { |
|
141 | 141 | throw new UnexpectedValueException(sprintf( |
142 | 142 | 'El RUT no puede ser mayor a %s y se encontró el valor %s.', |
143 | 143 | self::addThousandsSeparator(self::RUT_MAX), |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | // Validar que el DV sea correcto para el RUT. |
157 | - $real_dv = self::calculateDv((int) $rut); |
|
158 | - if ($dv !== $real_dv) { |
|
157 | + $real_dv = self::calculateDv((int)$rut); |
|
158 | + if ($dv!==$real_dv) { |
|
159 | 159 | throw new UnexpectedValueException(sprintf( |
160 | 160 | 'El dígito verificador del RUT %s es incorrecto. Se encontró el valor "%s" y para la parte numérica %s del RUT se espera que el dígito verificador sea "%s".', |
161 | 161 | self::formatFull($originalRut), |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | { |
177 | 177 | $rut = self::removeThousandsSeparatorAndDash($rut); |
178 | 178 | |
179 | - return (int) substr($rut, 0, -1); |
|
179 | + return (int)substr($rut, 0, -1); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public static function addDv(int $rut): string |
190 | 190 | { |
191 | - return ((string) $rut) . self::calculateDv($rut); |
|
191 | + return ((string)$rut).self::calculateDv($rut); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -253,6 +253,6 @@ discard block |
||
253 | 253 | { |
254 | 254 | [$rut, $dv] = self::toArray($rut); |
255 | 255 | |
256 | - return $rut . '-' . $dv; |
|
256 | + return $rut.'-'.$dv; |
|
257 | 257 | } |
258 | 258 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $csv->setEnclosure($textDelimiter); |
59 | 59 | return iterator_to_array($csv->getRecords()); |
60 | 60 | } catch (\Exception $e) { |
61 | - throw new RuntimeException('Error al leer el CSV desde el string: ' . $e->getMessage()); |
|
61 | + throw new RuntimeException('Error al leer el CSV desde el string: '.$e->getMessage()); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | ): void { |
121 | 121 | $csvString = self::generate($data, $separator, $textDelimiter); |
122 | 122 | |
123 | - if (@file_put_contents($file, $csvString) === false) { |
|
123 | + if (@file_put_contents($file, $csvString)===false) { |
|
124 | 124 | throw new LogicException(sprintf( |
125 | 125 | 'No se pudo escribir el archivo CSV en la ruta: %s', |
126 | 126 | $file |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | if ($sendHttpHeaders) { |
150 | 150 | header('Content-Type: text/csv'); |
151 | - header('Content-Disposition: attachment; filename="' . $file . '.csv"'); |
|
151 | + header('Content-Disposition: attachment; filename="'.$file.'.csv"'); |
|
152 | 152 | header('Pragma: no-cache'); |
153 | 153 | header('Expires: 0'); |
154 | 154 | } |