ConvenioConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 28
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toBarcode() 0 8 2
A toWritableLine() 0 10 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