Passed
Push — master ( 927f67...9bd000 )
by Claudson
06:56
created

Saldo   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 30
dl 0
loc 50
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A matches() 0 3 1
1
<?php
2
3
namespace Claudsonm\Pedi\Standards\PagSeguro\Records;
4
5
use Claudsonm\Pedi\Standards\PagSeguro\Enums\TipoRegistro;
6
use Claudsonm\Pedi\Structure\Field;
7
use Claudsonm\Pedi\Structure\Record;
8
use Claudsonm\Pedi\Structure\Types\Numeric;
9
10
class Saldo extends Record
11
{
12
    private array $definitions = [
13
        [
14
            'size' => 1,
15
            'start' => 1,
16
            'type' => Numeric::class,
17
            'name' => 'TIPO_REGISTRO',
18
        ],
19
        [
20
            'size' => 10,
21
            'start' => 2,
22
            'type' => Numeric::class,
23
            'name' => 'ESTABELECIMENTO',
24
        ],
25
        [
26
            'size' => 8,
27
            'start' => 12,
28
            'type' => Numeric::class,
29
            'name' => 'DATA_MOVIMENTACAO',
30
        ],
31
        [
32
            'size' => 2,
33
            'start' => 20,
34
            'type' => Numeric::class,
35
            'name' => 'TIPO_EVENTO',
36
        ],
37
        [
38
            'size' => 13,
39
            'start' => 22,
40
            'type' => Numeric::class,
41
            'name' => 'VALOR_SALDO',
42
        ],
43
    ];
44
45
    public function __construct()
46
    {
47
        foreach ($this->definitions as $definition) {
48
            $field = (new Field())
49
                ->setSize($definition['size'])
50
                ->setStart($definition['start'])
51
                ->setType(new $definition['type']())
52
                ->setName($definition['name']);
53
            $this->add($field);
54
        }
55
    }
56
57
    public function matches(string $line): bool
58
    {
59
        return TipoRegistro::SALDO === substr($line, 0, 1);
60
    }
61
}
62