Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions 14 src/Banco/Safra.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
return '1';
}

return (11 - $resto);
return (string) (11 - $resto);
}

/**
Expand Down Expand Up @@ -339,10 +339,10 @@
* @param string $conta
* @return $this
*/
public function setConta($conta)

Check failure on line 342 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.2)

Parameter #1 $conta (string) of method OpenBoleto\Banco\Safra::setConta() should be compatible with parameter $conta (int) of method OpenBoleto\BoletoAbstract::setConta()

Check failure on line 342 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Parameter #1 $conta (string) of method OpenBoleto\Banco\Safra::setConta() should be compatible with parameter $conta (int) of method OpenBoleto\BoletoAbstract::setConta()

Check failure on line 342 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Parameter #1 $conta (string) of method OpenBoleto\Banco\Safra::setConta() should be compatible with parameter $conta (int) of method OpenBoleto\BoletoAbstract::setConta()

Check failure on line 342 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.3)

Parameter #1 $conta (string) of method OpenBoleto\Banco\Safra::setConta() should be compatible with parameter $conta (int) of method OpenBoleto\BoletoAbstract::setConta()

Check failure on line 342 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Parameter #1 $conta (string) of method OpenBoleto\Banco\Safra::setConta() should be compatible with parameter $conta (int) of method OpenBoleto\BoletoAbstract::setConta()
{
$conta = preg_replace('/[^0-9]/', '', $conta);
$this->conta = $conta;
$conta = preg_replace('/[^0-9]/', '', (string) $conta);
$this->conta = (int) $conta;
return $this;
}

Expand All @@ -354,18 +354,18 @@
*/
public function setContaDv($contaDv)
{
$this->contaDv = (string) $contaDv;
$this->contaDv = (int) $contaDv;
return $this;
}

/**
* Retorna o DV da conta
*
* @return string
* @return int
*/
public function getContaDV()
{
return $this->contaDv ?? '0';
return $this->contaDv ?? 0;

Check failure on line 368 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.2)

Property OpenBoleto\BoletoAbstract::$contaDv (int) on left side of ?? is not nullable.

Check failure on line 368 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.1)

Property OpenBoleto\BoletoAbstract::$contaDv (int) on left side of ?? is not nullable.

Check failure on line 368 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (7.4)

Property OpenBoleto\BoletoAbstract::$contaDv (int) on left side of ?? is not nullable.

Check failure on line 368 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.3)

Property OpenBoleto\BoletoAbstract::$contaDv (int) on left side of ?? is not nullable.

Check failure on line 368 in src/Banco/Safra.php

View workflow job for this annotation

GitHub Actions / Testes Automatizados (8.0)

Property OpenBoleto\BoletoAbstract::$contaDv (int) on left side of ?? is not nullable.
}

/**
Expand Down Expand Up @@ -401,7 +401,7 @@
$fator = 1000 + ($fator % 1000);
}

$this->fatorVencimento = str_pad($fator, 4, '0', STR_PAD_LEFT);
$this->fatorVencimento = str_pad((string) $fator, 4, '0', STR_PAD_LEFT);
return $this;
}

Expand Down
53 changes: 42 additions & 11 deletions 53 src/Banco/Sicredi.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,56 @@ protected function gerarNossoNumero()
{
$ano = date("y");

$numero = self::zeroFill($this->getAgencia(), 4) .
self::zeroFill($this->getPosto(), 2) .
self::zeroFill($this->getCodigoCliente(), 5) .
self::zeroFill($ano, 2) .
$this->bytecode .
self::zeroFill($this->getSequencial(), 5);
$baseCalculo = self::zeroFill($this->getAgencia(), 4) .
self::zeroFill($this->getPosto(), 2) .
self::zeroFill($this->getCodigoCliente(), 5) .
self::zeroFill($ano, 2) .
$this->bytecode .
self::zeroFill($this->getSequencial(), 5);

$dv = static::modulo11($numero);
$dv = $this->calcularDvModulo11($baseCalculo);

return self::zeroFill($ano, 2) . '/' . $this->bytecode . self::zeroFill($this->getSequencial(), 5) . '-' . $dv['digito'];
return self::zeroFill($ano, 2) . '/' .
$this->bytecode .
self::zeroFill($this->getSequencial(), 5) .
'-' . $dv;
}
/**
* Calcula dígito verificador módulo 11
*
* @param string $numero Número base para cálculo
* @return int Dígito verificador calculado
*/
protected function calcularDvModulo11(string $numero): int
{
$soma = 0;
$peso = 2;

for ($i = strlen($numero) - 1; $i >= 0; $i--) {
$soma += (int)$numero[$i] * $peso;
$peso++;
if ($peso > 9) {
$peso = 2;
}
}

$resto = $soma % 11;

if ($resto == 0 || $resto == 1) {
return 0;
}

$digito = 11 - $resto;

return ($digito == 10 || $digito == 11) ? 0 : $digito;
}
/**
* Método para gerar o código da posição de 20 a 44
*
* @return string
* @throws \OpenBoleto\Exception
*/
public function getCampoLivre()
public function getCampoLivre(): string
{
$numero = $this->tipoCobranca .
'1' .
Expand All @@ -160,9 +191,9 @@ public function getCampoLivre()
'1' .
'0';

$dv = static::modulo11($numero);
$dv = $this->calcularDvModulo11($numero);

return $numero . $dv['digito'];
return $numero . $dv;
}

/**
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.