Skip to content

Commit e155000

Browse files
author
Matheus Lopes Santos
committed
Adição da validação da quantidade de mensagens para o ficha de compensação e recibo do pagador
1 parent eeb1c1c commit e155000

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/Boleto.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
use Boleto\Caixa\Interfaces\BoletoInterface;
66
use Carbon\Carbon;
77
use Boleto\Caixa\Interfaces\AgenteInterface as Agente;
8+
use Exception;
89
use InvalidArgumentException;
910
use JansenFelipe\Utils\Utils;
1011

1112
/**
1213
* Boleto
1314
*
1415
* @author Matheus Lopes Santos <fale_com_lopez@hotmail.com>
15-
* @version 1.0.0
16-
* @since 17/09/2018
16+
* @version 1.0.1
17+
* @since 19/09/2018
1718
* @package Boleto\Caixa
1819
*/
1920
class Boleto implements BoletoInterface
@@ -370,6 +371,7 @@ public function getFichaCompensacao()
370371

371372
/**
372373
* @param string $mensagem
374+
* @throws InvalidArgumentException|Exception
373375
*/
374376
public function setFichaCompensacao($mensagem)
375377
{
@@ -382,6 +384,10 @@ public function setFichaCompensacao($mensagem)
382384
throw new InvalidArgumentException('A mensagem deve ter no máximo 40 caracteres');
383385
}
384386

387+
if ( count($this->fichaCompensacao) > 2 ) {
388+
throw new Exception('São permitidas apenas 2 mensagens para este campo');
389+
}
390+
385391
array_push($this->fichaCompensacao, $mensagem);
386392
}
387393
}
@@ -396,6 +402,7 @@ public function getReciboPagador()
396402

397403
/**
398404
* @param string $mensagem
405+
* @throws InvalidArgumentException|Exception
399406
*/
400407
public function setReciboPagador($mensagem)
401408
{
@@ -408,6 +415,10 @@ public function setReciboPagador($mensagem)
408415
throw new InvalidArgumentException('A mensagem deve ter no máximo 40 caracteres');
409416
}
410417

418+
if ( count($this->reciboPagador) > 4 ) {
419+
throw new Exception('São permitidas apenas 4 mensagens para este campo');
420+
}
421+
411422
array_push($this->reciboPagador, $mensagem);
412423
}
413424
}

0 commit comments

Comments
 (0)