ConvenioConverter::toWritableLine()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 10
cc 3
nc 3
nop 1
crap 3
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
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 ignore-type  annotation

20
        return implode('', /** @scrutinizer ignore-type */ $blocks);
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
Bug introduced by
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 ignore-type  annotation

35
        return implode('', /** @scrutinizer ignore-type */ $blocks);
Loading history...
36
    }
37
}
38