Passed
Push — master ( 08379c...c55c96 )
by Claudson
07:14
created

Saldo   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 1
    public function __construct()
46
    {
47 1
        foreach ($this->definitions as $definition) {
48 1
            $field = (new Field())
49 1
                ->setSize($definition['size'])
50 1
                ->setStart($definition['start'])
51 1
                ->setType(new $definition['type']())
52 1
                ->setName($definition['name']);
53 1
            $this->add($field);
54
        }
55 1
    }
56
57 1
    public function matches(string $line): bool
58
    {
59 1
        return TipoRegistro::SALDO === substr($line, 0, 1);
60
    }
61
}
62