1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace BitWasp\Bitcoin\Serializer; |
6
|
|
|
|
7
|
|
|
use BitWasp\Buffertools\CachingTypeFactory; |
8
|
|
|
use BitWasp\Buffertools\Types\ByteString; |
9
|
|
|
use BitWasp\Buffertools\Types\Int128; |
10
|
|
|
use BitWasp\Buffertools\Types\Int16; |
11
|
|
|
use BitWasp\Buffertools\Types\Int256; |
12
|
|
|
use BitWasp\Buffertools\Types\Int32; |
13
|
|
|
use BitWasp\Buffertools\Types\Int64; |
14
|
|
|
use BitWasp\Buffertools\Types\Int8; |
15
|
|
|
use BitWasp\Buffertools\Types\Uint128; |
16
|
|
|
use BitWasp\Buffertools\Types\Uint16; |
17
|
|
|
use BitWasp\Buffertools\Types\Uint256; |
18
|
|
|
use BitWasp\Buffertools\Types\Uint32; |
19
|
|
|
use BitWasp\Buffertools\Types\Uint64; |
20
|
|
|
use BitWasp\Buffertools\Types\Uint8; |
21
|
|
|
use BitWasp\Buffertools\Types\VarInt; |
22
|
|
|
use BitWasp\Buffertools\Types\VarString; |
23
|
|
|
|
24
|
|
|
class Types |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @return CachingTypeFactory |
28
|
|
|
*/ |
29
|
5544 |
|
public static function factory() |
30
|
|
|
{ |
31
|
5544 |
|
static $factory; |
32
|
5544 |
|
if (null === $factory) { |
33
|
|
|
$factory = new CachingTypeFactory(); |
34
|
|
|
} |
35
|
|
|
|
36
|
5544 |
|
return $factory; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param int $length |
41
|
|
|
* @return ByteString |
42
|
|
|
*/ |
43
|
83 |
|
public static function bytestring($length) |
44
|
|
|
{ |
45
|
83 |
|
return static::factory()->{__FUNCTION__}($length); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param int $length |
50
|
|
|
* @return ByteString |
51
|
|
|
*/ |
52
|
5450 |
|
public static function bytestringle($length) |
53
|
|
|
{ |
54
|
5450 |
|
return static::factory()->{__FUNCTION__}($length); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return Uint8 |
59
|
|
|
*/ |
60
|
83 |
|
public static function uint8() |
61
|
|
|
{ |
62
|
83 |
|
return static::factory()->{__FUNCTION__}(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return Uint8 |
67
|
|
|
*/ |
68
|
8 |
|
public static function uint8le() |
69
|
|
|
{ |
70
|
8 |
|
return static::factory()->{__FUNCTION__}(); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return Uint16 |
75
|
|
|
*/ |
76
|
|
|
public static function uint16() |
77
|
|
|
{ |
78
|
|
|
return static::factory()->{__FUNCTION__}(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return Uint16 |
83
|
|
|
*/ |
84
|
|
|
public static function uint16le() |
85
|
|
|
{ |
86
|
|
|
return static::factory()->{__FUNCTION__}(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return Uint32 |
91
|
|
|
*/ |
92
|
83 |
|
public static function uint32() |
93
|
|
|
{ |
94
|
83 |
|
return static::factory()->{__FUNCTION__}(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return Uint32 |
99
|
|
|
*/ |
100
|
5447 |
|
public static function uint32le() |
101
|
|
|
{ |
102
|
5447 |
|
return static::factory()->{__FUNCTION__}(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return Uint64 |
107
|
|
|
*/ |
108
|
|
|
public static function uint64() |
109
|
|
|
{ |
110
|
|
|
return static::factory()->{__FUNCTION__}(); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return Uint64 |
115
|
|
|
*/ |
116
|
5246 |
|
public static function uint64le() |
117
|
|
|
{ |
118
|
5246 |
|
return static::factory()->{__FUNCTION__}(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return Uint128 |
123
|
|
|
*/ |
124
|
|
|
public static function uint128() |
125
|
|
|
{ |
126
|
|
|
return static::factory()->{__FUNCTION__}(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return Uint128 |
131
|
|
|
*/ |
132
|
|
|
public static function uint128le() |
133
|
|
|
{ |
134
|
|
|
return static::factory()->{__FUNCTION__}(); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return Uint256 |
139
|
|
|
*/ |
140
|
|
|
public static function uint256() |
141
|
|
|
{ |
142
|
|
|
return static::factory()->{__FUNCTION__}(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return Uint256 |
147
|
|
|
*/ |
148
|
|
|
public static function uint256le() |
149
|
|
|
{ |
150
|
|
|
return static::factory()->{__FUNCTION__}(); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return Int8 |
155
|
|
|
*/ |
156
|
|
|
public static function int8() |
157
|
|
|
{ |
158
|
|
|
return static::factory()->{__FUNCTION__}(); |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return Int8 |
163
|
|
|
*/ |
164
|
|
|
public static function int8le() |
165
|
|
|
{ |
166
|
|
|
return static::factory()->{__FUNCTION__}(); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return Int16 |
171
|
|
|
*/ |
172
|
|
|
public static function int16() |
173
|
|
|
{ |
174
|
|
|
return static::factory()->{__FUNCTION__}(); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* @return Int16 |
179
|
|
|
*/ |
180
|
|
|
public static function int16le() |
181
|
|
|
{ |
182
|
|
|
return static::factory()->{__FUNCTION__}(); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* @return Int32 |
187
|
|
|
*/ |
188
|
|
|
public static function int32() |
189
|
|
|
{ |
190
|
|
|
return static::factory()->{__FUNCTION__}(); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return Int32 |
195
|
|
|
*/ |
196
|
5439 |
|
public static function int32le() |
197
|
|
|
{ |
198
|
5439 |
|
return static::factory()->{__FUNCTION__}(); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* @return Int64 |
203
|
|
|
*/ |
204
|
|
|
public static function int64() |
205
|
|
|
{ |
206
|
|
|
return static::factory()->{__FUNCTION__}(); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* @return Int64 |
211
|
|
|
*/ |
212
|
|
|
public static function int64le() |
213
|
|
|
{ |
214
|
|
|
return static::factory()->{__FUNCTION__}(); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* @return Int128 |
219
|
|
|
*/ |
220
|
|
|
public static function int128() |
221
|
|
|
{ |
222
|
|
|
return static::factory()->{__FUNCTION__}(); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* @return Int128 |
227
|
|
|
*/ |
228
|
|
|
public static function int128le() |
229
|
|
|
{ |
230
|
|
|
return static::factory()->{__FUNCTION__}(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* @return Int256 |
235
|
|
|
*/ |
236
|
|
|
public static function int256() |
237
|
|
|
{ |
238
|
|
|
return static::factory()->{__FUNCTION__}(); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* @return Int256 |
243
|
|
|
*/ |
244
|
|
|
public static function int256le() |
245
|
|
|
{ |
246
|
|
|
return static::factory()->{__FUNCTION__}(); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @return VarInt |
251
|
|
|
*/ |
252
|
5256 |
|
public static function varint() |
253
|
|
|
{ |
254
|
5256 |
|
return static::factory()->{__FUNCTION__}(); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
/** |
258
|
|
|
* @return VarString |
259
|
|
|
*/ |
260
|
5255 |
|
public static function varstring() |
261
|
|
|
{ |
262
|
5255 |
|
return static::factory()->{__FUNCTION__}(); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* @param callable $reader |
267
|
|
|
* @return \BitWasp\Buffertools\Types\Vector |
268
|
|
|
*/ |
269
|
|
|
public static function vector(callable $reader) |
270
|
|
|
{ |
271
|
|
|
return static::factory()->vector($reader); |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
|