claudsonm /
boleto-winner
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Claudsonm\BoletoWinner\Converters; |
||||
| 4 | |||||
| 5 | use Claudsonm\BoletoWinner\Bill; |
||||
| 6 | use Claudsonm\BoletoWinner\Convenio; |
||||
| 7 | |||||
| 8 | class ConvenioConverter implements Converter |
||||
| 9 | { |
||||
| 10 | /** |
||||
| 11 | * {@inheritdoc} |
||||
| 12 | */ |
||||
| 13 | 2 | public function toBarcode(Bill $bill): string |
|||
| 14 | { |
||||
| 15 | 2 | $blocks = str_split($bill->getWritableLine(), 12); |
|||
| 16 | 2 | foreach ($blocks as &$block) { |
|||
| 17 | 2 | $block = substr($block, 0, -1); |
|||
| 18 | } |
||||
| 19 | |||||
| 20 | 2 | return implode('', $blocks); |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 21 | } |
||||
| 22 | |||||
| 23 | /** |
||||
| 24 | * {@inheritdoc} |
||||
| 25 | */ |
||||
| 26 | 1 | public function toWritableLine(Bill $bill): string |
|||
| 27 | { |
||||
| 28 | 1 | $barcode = $bill->getBarcode(); |
|||
| 29 | 1 | $blocks = str_split($barcode, 11); |
|||
| 30 | 1 | $isModule10 = in_array($barcode[2], Convenio::USES_MODULE_10); |
|||
| 31 | 1 | foreach ($blocks as &$block) { |
|||
| 32 | 1 | $block .= $isModule10 ? module10($block) : module11($block); |
|||
| 33 | } |
||||
| 34 | |||||
| 35 | 1 | return implode('', $blocks); |
|||
|
0 ignored issues
–
show
It seems like
$blocks can also be of type true; however, parameter $pieces of implode() does only seem to accept array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 36 | } |
||||
| 37 | } |
||||
| 38 |