Skip to content

Commit 5e62ff5

Browse files
style: PSR12 standards
1 parent 89dd063 commit 5e62ff5

File tree

13 files changed

+14
-77
lines changed

13 files changed

+14
-77
lines changed

modules/addons/NFEioServiceInvoices/callback.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function findSignatureHeader($headers)
3737
$headers = array_change_key_case($headers, CASE_LOWER);
3838
// retorna os possiveis cabecalhos de assinatura da requisicao (X-Hub-Signature e X-Nfeio-Signature)
3939
return $headers['x-hub-signature'] ?? $headers['x-nfeio-signature'] ?? null;
40-
4140
}
4241

4342
// cabecalho com a assinatura
@@ -82,7 +81,7 @@ function findSignatureHeader($headers)
8281

8382
logModuleCall('nfeio_serviceinvoices', 'callback', 'Webhook Raw Payload', ['headers' => $headers, 'body' => $payload]);
8483

85-
if(!is_array($payload) || ( !isset($payload['id']) && !isset($payload['status']) && !isset($payload['flowStatus']) && !isset($payload['environment']) )){
84+
if (!is_array($payload) || ( !isset($payload['id']) && !isset($payload['status']) && !isset($payload['flowStatus']) && !isset($payload['environment']) )) {
8685
logModuleCall('nfeio_serviceinvoices', 'callback_error', 'Payload inválido', ['headers' => $headers, 'body' => $payload]);
8786
// https://developer.mozilla.org/pt-BR/docs/Web/HTTP/Status/400
8887
http_response_code(400);

modules/addons/NFEioServiceInvoices/lib/Admin/Controller.php

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public function associateClients($vars)
8787
}
8888

8989
return $template->fetch('associateclients', $vars);
90-
91-
9290
}
9391

9492
/**
@@ -117,27 +115,21 @@ public function associateClientsSave($vars)
117115
}
118116

119117
try {
120-
121118
// inicializa o repositório de empresas
122119
$clientCompanyRepository = new \NFEioServiceInvoices\Models\ClientCompany\Repository();
123120
// associa o cliente a empresa
124121
$response = $clientCompanyRepository->new($client_id, $company_id);
125122

126123
// verifica se houve erro na associação
127124
if (!$response['status']) {
128-
129125
$msg->error("SQL error occurred: " . $response['error'], "{$vars['modulelink']}&action=associateClients");
130-
131126
} else {
132-
133127
// registra atividade no WHMCS
134128
logActivity("NFE.io: Client associated - " . $client_id, 0);
135129

136130
$msg->success("Cliente associado com sucesso.", "{$vars['modulelink']}&action=associateClients");
137131
}
138-
139132
} catch (\Exception $exception) {
140-
141133
logModuleCall(
142134
'nfeio_serviceinvoices',
143135
'associateClients',
@@ -152,7 +144,6 @@ public function associateClientsSave($vars)
152144
);
153145
$msg->error("Error {$exception->getCode()} updating: " . $exception->getMessage(), "{$vars['modulelink']}&action=associateClients");
154146
}
155-
156147
}
157148

158149
/**
@@ -183,7 +174,6 @@ public function associateClientsRemove($vars)
183174
} else {
184175
$msg->error("Erro ao excluir: {$result['message']}", "{$vars['modulelink']}&action=associateClients");
185176
}
186-
187177
}
188178

189179
/**
@@ -204,7 +194,6 @@ public function searchClients($vars)
204194
header('Content-Type: application/json');
205195

206196
try {
207-
208197
// obtém o termo de pesquisa da requisição GET
209198
$searchTerm = $_GET['term'] ?? '';
210199

@@ -228,7 +217,6 @@ public function searchClients($vars)
228217

229218
// retorna os resultados em formato JSON
230219
echo json_encode($clients);
231-
232220
} catch (\Exception $e) {
233221
// em caso de erro, retorna uma mensagem de erro em JSON
234222
echo json_encode(['error' => $e->getMessage()]);
@@ -268,7 +256,6 @@ public function companyEdit($vars)
268256
}
269257

270258
try {
271-
272259
// inicializa o repositório de empresas
273260
$companyRepository = new \NFEioServiceInvoices\Models\Company\Repository();
274261
// edita os dados da empresa
@@ -282,11 +269,8 @@ public function companyEdit($vars)
282269

283270
// verifica se houve erro na edição
284271
if (!$response['status']) {
285-
286272
$msg->error("SQL error occurred: " . $response['error'], "{$vars['modulelink']}&action=configuration");
287-
288273
} else {
289-
290274
// registra atividade no WHMCS
291275
logActivity("NFE.io: Company updated - " . $recordId, 0);
292276

@@ -295,7 +279,6 @@ public function companyEdit($vars)
295279
} catch (\Exception $exception) {
296280
$msg->error("Error {$exception->getCode()} updating: " . $exception->getMessage(), "{$vars['modulelink']}&action=configuration");
297281
}
298-
299282
}
300283

301284
/**
@@ -320,7 +303,6 @@ public function companyDelete($vars)
320303
} else {
321304
$msg->error("Erro ao excluir: {$result['message']}", "{$vars['modulelink']}&action=configuration");
322305
}
323-
324306
}
325307

326308
/**
@@ -358,7 +340,6 @@ public function associateCompany($vars)
358340
}
359341

360342
try {
361-
362343
$nfe = new \NFEioServiceInvoices\NFEio\Nfe();
363344
$companyRepository = new \NFEioServiceInvoices\Models\Company\Repository();
364345
$company_details = $nfe->getCompanyDetails($company_id);
@@ -377,18 +358,14 @@ public function associateCompany($vars)
377358

378359
// verifica se houve erro na associação
379360
if (!$response['status']) {
380-
381361
$msg->error("SQL error occurred: " . $response['error'], "{$vars['modulelink']}&action=configuration");
382-
383362
} else {
384-
385363
// registra atividade no WHMCS
386364
logActivity("NFE.io: Company associated - " . $company_id, 0);
387365

388366
$msg->success("Empresa associada com sucesso!", "{$vars['modulelink']}&action=configuration");
389367
}
390368
} catch (\Exception $exception) {
391-
392369
// registra erro na chamada do módulo
393370
logModuleCall(
394371
'nfeio_serviceinvoices',
@@ -594,7 +571,6 @@ public function searchProducts()
594571

595572
// retorna os resultados em formato JSON
596573
echo json_encode($products);
597-
598574
} catch (\Exception $e) {
599575
// em caso de erro, retorna uma mensagem de erro em JSON
600576
echo json_encode(['error' => $e->getMessage()]);
@@ -679,20 +655,16 @@ public function serviceCodeRemove($vars)
679655
}
680656

681657
try {
682-
683658
// inicializa o repositório de códigos de serviços
684659
$productCodeRepository = new \NFEioServiceInvoices\Models\ProductCode\Repository();
685660
// remove o código de serviço usando o id do registro
686661
$productCodeRepository->delete($record_id);
687662
// retorna sucesso
688663
$msg->success('Código de serviço removido com sucesso.', "{$vars['modulelink']}&action=servicesCode");
689-
690664
} catch (Exception $exception) {
691665
// retorna erro
692666
$msg->error("Erro {$exception->getCode()} ao atualizar: {$exception->getMessage()}", "{$vars['modulelink']}&action=servicesCode");
693667
}
694-
695-
696668
}
697669

698670
/**
@@ -735,7 +707,6 @@ public function servicesCodeSave($vars)
735707

736708
// verifica se houve erro na associação
737709
if ($response) {
738-
739710
// registra atividade no WHMCS
740711
logActivity('NFE.io: Código de serviço atualizado - Produto: ' . $product_id . ' Código: ' . $service_code, 0);
741712
// retorna sucesso
@@ -744,7 +715,6 @@ public function servicesCodeSave($vars)
744715
// retorna erro
745716
$msg->info("Nenhuma alteração realizada.", "{$vars['modulelink']}&action=servicesCode");
746717
}
747-
748718
}
749719

750720
/**
@@ -925,7 +895,6 @@ public function aliquotsRemove($vars)
925895
$aliquotsRepo->delete($record_id);
926896
// retorna sucesso
927897
$msg->success('Alíquota removida com sucesso.', "{$vars['modulelink']}&action=aliquots");
928-
929898
} catch (Exception $exception) {
930899
// retorna erro
931900
$msg->error("Erro {$exception->getCode()} ao atualizar: {$exception->getMessage()}", "{$vars['modulelink']}&action=aliquots");
@@ -974,7 +943,6 @@ public function aliquotsSave($vars)
974943
} else {
975944
$msg->info("Nenhuma alteração realizada.", "{$vars['modulelink']}&action=aliquots");
976945
}
977-
978946
}
979947

980948
/**
@@ -1019,7 +987,6 @@ public function aliquotsEdit($vars)
1019987
} else {
1020988
$msg->info("Nenhuma alteração realizada.", "{$vars['modulelink']}&action=aliquots");
1021989
}
1022-
1023990
}
1024991

1025992
/**

modules/addons/NFEioServiceInvoices/lib/Configuration.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,14 @@ public function upgrade($vars)
300300
*
301301
* @see https://github.com/nfe/whmcs-addon/issues/156
302302
*/
303-
if(version_compare($currentlyInstalledVersion, '2.1.8', 'le')) {
304-
303+
if (version_compare($currentlyInstalledVersion, '2.1.8', 'le')) {
305304
// atualiza o nome da coluna de timestamp para a tabela productcode
306305
\NFEioServiceInvoices\Migrations\Migrations::changeProductCodeTimestampColumnsName();
307306

308307
// altera as colunas de timestamp para as tabelas
309308
\NFEioServiceInvoices\Migrations\Migrations::migrateTimestampColumns('mod_nfeio_si_productcode');
310309
\NFEioServiceInvoices\Migrations\Migrations::migrateTimestampColumns('mod_nfeio_si_serviceinvoices');
311310
\NFEioServiceInvoices\Migrations\Migrations::migrateTimestampColumns('mod_nfeio_si_aliquots');
312-
313311
}
314312

315313
/**
@@ -320,7 +318,6 @@ public function upgrade($vars)
320318
* @version 3.0
321319
*/
322320
if (version_compare($currentlyInstalledVersion, '3.0.0', 'lt')) {
323-
324321
// inicia tabela para armazenar as empresas
325322
$companyRepository = new Models\Company\Repository();
326323
$companyRepository->createTable();
@@ -361,7 +358,6 @@ public function upgrade($vars)
361358
\NFEioServiceInvoices\Migrations\Migrations::addCompanyIdRecord($company_id, 'mod_nfeio_si_aliquots');
362359
// mod_nfeio_si_serviceinvoices
363360
\NFEioServiceInvoices\Migrations\Migrations::addCompanyIdRecord($company_id, 'mod_nfeio_si_serviceinvoices');
364-
365361
}
366362
}
367363
}

modules/addons/NFEioServiceInvoices/lib/Helpers/Timestamp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public static function currentTimestamp(): string
1414
{
1515
return date('Y-m-d H:i:s');
1616
}
17-
}
17+
}

modules/addons/NFEioServiceInvoices/lib/Helpers/Validations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function webhookHashValid(string $secret, $payload, string $signat
8181
*
8282
* @return string The computed hash.
8383
*/
84-
private function webhookComputeHash(string $algo, string $secret, $payload, bool $bencode = false): string
84+
private function webhookComputeHash(string $algo, string $secret, $payload, bool $bencode = false): string
8585
{
8686
$hex_hash = hash_hmac($algo, $payload, utf8_encode($secret));
8787
$result = $bencode ? base64_encode(hex2bin($hex_hash)) : hex2bin($hex_hash);

modules/addons/NFEioServiceInvoices/lib/Legacy/Functions.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,10 @@ function gnfe_ibge($zip)
181181
if ($data->city->code) {
182182
$result['code'] = $data->city->code;
183183
$result['success'] = true;
184-
185184
} else {
186185
$result['error'] = true;
187186
$result['message'] = $data->message;
188187
logModuleCall('nfeio_serviceinvoices', 'ibge_error', $zip, array('response' => $response, 'error' => $error));
189-
190188
}
191189

192190
return $result;
@@ -953,8 +951,7 @@ function createRequestFromAPI(
953951
$code,
954952
$city,
955953
$state
956-
)
957-
{
954+
) {
958955
$postfields = [
959956
'cityServiceCode' => $service_code,
960957
'description' => $desc,

modules/addons/NFEioServiceInvoices/lib/Migrations/Migrations.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ public static function migrateProductCodes()
211211
private function createAlterColumnTimestampStatement($pdo, $columnName, $tableName)
212212
{
213213
$statement = $pdo->prepare(
214-
sprintf('ALTER TABLE %s MODIFY COLUMN %s TIMESTAMP NULL',
214+
sprintf(
215+
'ALTER TABLE %s MODIFY COLUMN %s TIMESTAMP NULL',
215216
$tableName,
216217
$columnName
217218
)
@@ -253,7 +254,6 @@ public static function migrateTimestampColumns(string $tableName)
253254
if ($pdo->inTransaction()) {
254255
$pdo->rollBack();
255256
}
256-
257257
}
258258
}
259259
}
@@ -268,7 +268,6 @@ public static function changeProductCodeTimestampColumnsName()
268268
{
269269

270270
if (Capsule::schema()->hasTable('mod_nfeio_si_productcode')) {
271-
272271
// verifica se a coluna create_at e update_at já foram migradas (existem)
273272
$columns = Capsule::schema()->getColumnListing('mod_nfeio_si_productcode');
274273
if (!in_array('create_at', $columns) || !in_array('update_at', $columns)) {

modules/addons/NFEioServiceInvoices/lib/Models/Aliquots/Repository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ function ($table) {
176176

177177
// Adiciona a coluna updated_at com a configuração de auto update #156
178178
// $db->statement(sprintf('ALTER TABLE %s CHANGE updated_at updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $this->tableName));
179-
180179
}
181180
}
182181

modules/addons/NFEioServiceInvoices/lib/Models/ClientCompany/Repository.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
class Repository extends \WHMCSExpert\mtLibs\models\Repository
1919
{
20-
2120
public $tableName = 'mod_nfeio_si_clients_companies';
2221
public $fieldDeclaration = array(
2322
'id',
@@ -92,7 +91,8 @@ public function getAll()
9291
->join($this->tableName(), 'tblclients.id', '=', "{$this->tableName()}.client_id")
9392
->join($companyRepo->tableName(), "{$this->tableName()}.company_id", '=', "{$companyRepo->tableName()}.company_id")
9493
->orderBy("{$this->tableName()}.id", 'desc')
95-
->select("{$this->tableName()}.client_id",
94+
->select(
95+
"{$this->tableName()}.client_id",
9696
'tblclients.firstname as client_firstname',
9797
'tblclients.lastname as client_lastname',
9898
'tblclients.companyname as client_companyname',
@@ -102,8 +102,6 @@ public function getAll()
102102
"{$companyRepo->tableName()}.tax_number as company_tax_number",
103103
)
104104
->get();
105-
106-
107105
}
108106

109107
/**
@@ -137,14 +135,12 @@ public function new($clientId, $companyId)
137135
}
138136

139137
try {
140-
141138
Capsule::table($this->tableName())
142139
->insert($data);
143140
return array(
144141
'status' => true,
145142
'message' => 'Associacao criada com sucesso',
146143
);
147-
148144
} catch (\Exception $exception) {
149145
return array(
150146
'status' => false,
@@ -163,7 +159,6 @@ public function new($clientId, $companyId)
163159
public function delete($recordId)
164160
{
165161
try {
166-
167162
$result = \WHMCS\Database\Capsule::table($this->tableName())
168163
->where('id', '=', $recordId)
169164
->delete();
@@ -176,6 +171,4 @@ public function delete($recordId)
176171
return $exception->getMessage();
177172
}
178173
}
179-
180-
181-
}
174+
}

0 commit comments

Comments
 (0)