Skip to content

Commit

Permalink
Merge pull request #744 from thiagosouza84/master
Browse files Browse the repository at this point in the history
Refatoração: converter e-mails para minúsculas na atualização de chav…
  • Loading branch information
eduardokum authored Apr 29, 2024
2 parents 85c56f3 + 8775217 commit 4512025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Cnab/Remessa/Cnab400/Banco/Santander.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function addBoleto(BoletoContract $boleto)
$this->add(25, 37, Util::formatCnab('9', $boleto->getValor(), 13, 2));
$this->add(38, 42, Util::formatCnab('9', 100, 5, 2));
$this->add(43, 43, Util::formatCnab('9', $tipoChave[$boleto->getPixChaveTipo()], 1));
$this->add(44, 120, Util::formatCnab('X', $boleto->getPixChave(), 77));
$this->add(44, 120, Util::formatCnab('Z', $boleto->getPixChave(), 77));
$this->add(121, 155, Util::formatCnab('X', $boleto->getID(), 35));
$this->add(156, 394, '');
$this->add(395, 400, Util::formatCnab('9', $this->iRegistros + 1, 6));
Expand Down
9 changes: 7 additions & 2 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,19 @@ public static function formatCnab($tipo, $valor, $tamanho, $dec = 0, $sFill = ''
$type = 's';
$valor = ($dec > 0) ? sprintf("%.{$dec}f", $valor) : $valor;
$valor = str_replace([',', '.'], '', $valor);
} elseif (in_array($tipo, ['A', 'X'])) {
} elseif (in_array($tipo, ['A', 'X', 'Z'])) { // Adiciona 'x' como uma condição válida
$left = '-';
$type = 's';
} else {
throw new ValidationException('Tipo inválido');
}

return sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho));
// Verifica se o tipo é 'x' minúsculo e então retorna a string em minúsculas
if ($tipo === 'Z') {
return strtolower(sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho)));
} else {
return sprintf("%{$left}{$sFill}{$tamanho}{$type}", mb_substr($valor, 0, $tamanho));
}
}

/**
Expand Down

0 comments on commit 4512025

Please sign in to comment.