1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Claudsonm\Pedi\Standards\PagSeguro\Records; |
4
|
|
|
|
5
|
|
|
use Claudsonm\Pedi\Standards\PagSeguro\Enums\TipoRegistro; |
6
|
|
|
use Claudsonm\Pedi\Standards\PagSeguro\Types\Filler; |
7
|
|
|
use Claudsonm\Pedi\Structure\Field; |
8
|
|
|
use Claudsonm\Pedi\Structure\Record; |
9
|
|
|
use Claudsonm\Pedi\Structure\Types\Any; |
10
|
|
|
use Claudsonm\Pedi\Structure\Types\Numeric; |
11
|
|
|
|
12
|
|
|
class Header extends Record |
13
|
|
|
{ |
14
|
|
|
private array $definitions = [ |
15
|
|
|
[ |
16
|
|
|
'size' => 1, |
17
|
|
|
'start' => 1, |
18
|
|
|
'type' => Numeric::class, |
19
|
|
|
'name' => 'TIPO_REGISTRO', |
20
|
|
|
], |
21
|
|
|
[ |
22
|
|
|
'size' => 10, |
23
|
|
|
'start' => 2, |
24
|
|
|
'type' => Numeric::class, |
25
|
|
|
'name' => 'ESTABELECIMENTO', |
26
|
|
|
], |
27
|
|
|
[ |
28
|
|
|
'size' => 8, |
29
|
|
|
'start' => 12, |
30
|
|
|
'type' => Numeric::class, |
31
|
|
|
'name' => 'DATA_PROCESSAMENTO', |
32
|
|
|
], |
33
|
|
|
[ |
34
|
|
|
'size' => 8, |
35
|
|
|
'start' => 20, |
36
|
|
|
'type' => Numeric::class, |
37
|
|
|
'name' => 'DATA_INICIO', |
38
|
|
|
], |
39
|
|
|
[ |
40
|
|
|
'size' => 8, |
41
|
|
|
'start' => 28, |
42
|
|
|
'type' => Numeric::class, |
43
|
|
|
'name' => 'DATA_FIM', |
44
|
|
|
], |
45
|
|
|
[ |
46
|
|
|
'size' => 7, |
47
|
|
|
'start' => 36, |
48
|
|
|
'type' => Numeric::class, |
49
|
|
|
'name' => 'SEQUENCIA_ARQUIVO', |
50
|
|
|
], |
51
|
|
|
[ |
52
|
|
|
'size' => 5, |
53
|
|
|
'start' => 43, |
54
|
|
|
'type' => Any::class, |
55
|
|
|
'name' => 'ADQUIRENTE', |
56
|
|
|
], |
57
|
|
|
[ |
58
|
|
|
'size' => 2, |
59
|
|
|
'start' => 48, |
60
|
|
|
'type' => Numeric::class, |
61
|
|
|
'name' => 'TIPO_EXTRATO', |
62
|
|
|
], |
63
|
|
|
[ |
64
|
|
|
'size' => 21, |
65
|
|
|
'start' => 50, |
66
|
|
|
'type' => Filler::class, |
67
|
|
|
'name' => 'FILLER', |
68
|
|
|
], |
69
|
|
|
[ |
70
|
|
|
'size' => 3, |
71
|
|
|
'start' => 71, |
72
|
|
|
'type' => Any::class, |
73
|
|
|
'name' => 'VERSAO_LAYOUT', |
74
|
|
|
], |
75
|
|
|
[ |
76
|
|
|
'size' => 3, |
77
|
|
|
'start' => 74, |
78
|
|
|
'type' => Any::class, |
79
|
|
|
'name' => 'VERSAO_RELEASE', |
80
|
|
|
], |
81
|
|
|
[ |
82
|
|
|
'size' => 454, |
83
|
|
|
'start' => 77, |
84
|
|
|
'type' => Any::class, |
85
|
|
|
'name' => 'INTERNO_PAGSG', |
86
|
|
|
], |
87
|
|
|
]; |
88
|
|
|
|
89
|
43 |
|
public function __construct() |
90
|
|
|
{ |
91
|
43 |
|
foreach ($this->definitions as $definition) { |
92
|
43 |
|
$field = (new Field()) |
93
|
43 |
|
->setSize($definition['size']) |
94
|
43 |
|
->setStart($definition['start']) |
95
|
43 |
|
->setType(new $definition['type']()) |
96
|
43 |
|
->setName($definition['name']); |
97
|
43 |
|
$this->add($field); |
98
|
|
|
} |
99
|
43 |
|
} |
100
|
|
|
|
101
|
|
|
public function matches(string $line): bool |
102
|
|
|
{ |
103
|
|
|
return TipoRegistro::HEADER === substr($line, 0, 1); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|