Completed
Pull Request — master (#1)
by Sergey
04:51
created

Frame::encode()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/*
3
 * This file is automatically generated.
4
 */
5
6
namespace ButterAMQP\AMQP091\Framing;
7
8
use ButterAMQP\Buffer;
9
use ButterAMQP\Binary;
10
use ButterAMQP\Value;
11
12
/**
13
 * @codeCoverageIgnore
14
 */
15
abstract class Frame
16
{
17
    /**
18
     * @var int
19
     */
20
    protected $channel;
21
22
    /**
23
     * @param int $channel
24
     */
25
    public function __construct($channel)
26
    {
27
        $this->channel = $channel;
28
    }
29
30
    /**
31
     * @return int
32
     */
33
    public function getChannel()
34
    {
35
        return $this->channel;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    abstract public function encode();
42
43
    /**
44
     * @param array  $header
45
     * @param Buffer $data
46
     *
47
     * @return $this
48
     */
49
    public static function decode(array $header, Buffer $data)
50
    {
51
        if ($header['type'] === 1) {
52
            $class = $data->read(2);
53
            $method = $data->read(2);
54
55
            if ($class === "\x00\x0A") {
56 View Code Duplication
                if ($method === "\x00\x0A") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
57
                    return new Method\ConnectionStart(
58
                        $header['channel'],
59
                        Value\OctetValue::decode($data),
60
                        Value\OctetValue::decode($data),
61
                        Value\TableValue::decode($data),
62
                        Value\LongStringValue::decode($data),
63
                        Value\LongStringValue::decode($data)
64
                    );
65
                }
66 View Code Duplication
                if ($method === "\x00\x0B") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
                    return new Method\ConnectionStartOk(
68
                        $header['channel'],
69
                        Value\TableValue::decode($data),
70
                        Value\ShortStringValue::decode($data),
71
                        Value\LongStringValue::decode($data),
72
                        Value\ShortStringValue::decode($data)
73
                    );
74
                }
75
                if ($method === "\x00\x14") {
76
                    return new Method\ConnectionSecure(
77
                        $header['channel'],
78
                        Value\LongStringValue::decode($data)
79
                    );
80
                }
81
                if ($method === "\x00\x15") {
82
                    return new Method\ConnectionSecureOk(
83
                        $header['channel'],
84
                        Value\LongStringValue::decode($data)
85
                    );
86
                }
87 View Code Duplication
                if ($method === "\x00\x1E") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
88
                    return new Method\ConnectionTune(
89
                        $header['channel'],
90
                        Value\ShortValue::decode($data),
91
                        Value\LongValue::decode($data),
92
                        Value\ShortValue::decode($data)
93
                    );
94
                }
95 View Code Duplication
                if ($method === "\x00\x1F") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
96
                    return new Method\ConnectionTuneOk(
97
                        $header['channel'],
98
                        Value\ShortValue::decode($data),
99
                        Value\LongValue::decode($data),
100
                        Value\ShortValue::decode($data)
101
                    );
102
                }
103 View Code Duplication
                if ($method === "\x00\x28") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
104
                    return new Method\ConnectionOpen(
105
                        $header['channel'],
106
                        Value\ShortStringValue::decode($data),
107
                        Value\ShortStringValue::decode($data),
108
                        Value\BooleanValue::decode($data)
109
                    );
110
                }
111
                if ($method === "\x00\x29") {
112
                    return new Method\ConnectionOpenOk(
113
                        $header['channel'],
114
                        Value\ShortStringValue::decode($data)
115
                    );
116
                }
117
                if ($method === "\x00\x32") {
118
                    return new Method\ConnectionClose(
119
                        $header['channel'],
120
                        Value\ShortValue::decode($data),
121
                        Value\ShortStringValue::decode($data),
122
                        Value\ShortValue::decode($data),
123
                        Value\ShortValue::decode($data)
124
                    );
125
                }
126
                if ($method === "\x00\x33") {
127
                    return new Method\ConnectionCloseOk(
128
                        $header['channel']
129
                    );
130
                }
131
                if ($method === "\x00\x3C") {
132
                    return new Method\ConnectionBlocked(
133
                        $header['channel'],
134
                        Value\ShortStringValue::decode($data)
135
                    );
136
                }
137
                if ($method === "\x00\x3D") {
138
                    return new Method\ConnectionUnblocked(
139
                        $header['channel']
140
                    );
141
                }
142
            }
143
144
            if ($class === "\x00\x14") {
145
                if ($method === "\x00\x0A") {
146
                    return new Method\ChannelOpen(
147
                        $header['channel'],
148
                        Value\ShortStringValue::decode($data)
149
                    );
150
                }
151
                if ($method === "\x00\x0B") {
152
                    return new Method\ChannelOpenOk(
153
                        $header['channel'],
154
                        Value\LongStringValue::decode($data)
155
                    );
156
                }
157
                if ($method === "\x00\x14") {
158
                    return new Method\ChannelFlow(
159
                        $header['channel'],
160
                        Value\BooleanValue::decode($data)
161
                    );
162
                }
163
                if ($method === "\x00\x15") {
164
                    return new Method\ChannelFlowOk(
165
                        $header['channel'],
166
                        Value\BooleanValue::decode($data)
167
                    );
168
                }
169
                if ($method === "\x00\x28") {
170
                    return new Method\ChannelClose(
171
                        $header['channel'],
172
                        Value\ShortValue::decode($data),
173
                        Value\ShortStringValue::decode($data),
174
                        Value\ShortValue::decode($data),
175
                        Value\ShortValue::decode($data)
176
                    );
177
                }
178
                if ($method === "\x00\x29") {
179
                    return new Method\ChannelCloseOk(
180
                        $header['channel']
181
                    );
182
                }
183
            }
184
185
            if ($class === "\x00\x28") {
186 View Code Duplication
                if ($method === "\x00\x0A") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
187
                    return new Method\ExchangeDeclare(
188
                        $header['channel'],
189
                        Value\ShortValue::decode($data),
190
                        Value\ShortStringValue::decode($data),
191
                        Value\ShortStringValue::decode($data),
192
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
193
                        (bool) $flags & 2,
194
                        (bool) $flags & 4,
195
                        (bool) $flags & 8,
196
                        (bool) $flags & 16,
197
                        Value\TableValue::decode($data)
198
                    );
199
                }
200
                if ($method === "\x00\x0B") {
201
                    return new Method\ExchangeDeclareOk(
202
                        $header['channel']
203
                    );
204
                }
205
                if ($method === "\x00\x14") {
206
                    return new Method\ExchangeDelete(
207
                        $header['channel'],
208
                        Value\ShortValue::decode($data),
209
                        Value\ShortStringValue::decode($data),
210
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
211
                        (bool) $flags & 2
212
                    );
213
                }
214
                if ($method === "\x00\x15") {
215
                    return new Method\ExchangeDeleteOk(
216
                        $header['channel']
217
                    );
218
                }
219 View Code Duplication
                if ($method === "\x00\x1E") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
220
                    return new Method\ExchangeBind(
221
                        $header['channel'],
222
                        Value\ShortValue::decode($data),
223
                        Value\ShortStringValue::decode($data),
224
                        Value\ShortStringValue::decode($data),
225
                        Value\ShortStringValue::decode($data),
226
                        Value\BooleanValue::decode($data),
227
                        Value\TableValue::decode($data)
228
                    );
229
                }
230
                if ($method === "\x00\x1F") {
231
                    return new Method\ExchangeBindOk(
232
                        $header['channel']
233
                    );
234
                }
235 View Code Duplication
                if ($method === "\x00\x28") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
236
                    return new Method\ExchangeUnbind(
237
                        $header['channel'],
238
                        Value\ShortValue::decode($data),
239
                        Value\ShortStringValue::decode($data),
240
                        Value\ShortStringValue::decode($data),
241
                        Value\ShortStringValue::decode($data),
242
                        Value\BooleanValue::decode($data),
243
                        Value\TableValue::decode($data)
244
                    );
245
                }
246
                if ($method === "\x00\x33") {
247
                    return new Method\ExchangeUnbindOk(
248
                        $header['channel']
249
                    );
250
                }
251
            }
252
253
            if ($class === "\x00\x32") {
254 View Code Duplication
                if ($method === "\x00\x0A") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
255
                    return new Method\QueueDeclare(
256
                        $header['channel'],
257
                        Value\ShortValue::decode($data),
258
                        Value\ShortStringValue::decode($data),
259
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
260
                        (bool) $flags & 2,
261
                        (bool) $flags & 4,
262
                        (bool) $flags & 8,
263
                        (bool) $flags & 16,
264
                        Value\TableValue::decode($data)
265
                    );
266
                }
267
                if ($method === "\x00\x0B") {
268
                    return new Method\QueueDeclareOk(
269
                        $header['channel'],
270
                        Value\ShortStringValue::decode($data),
271
                        Value\LongValue::decode($data),
272
                        Value\LongValue::decode($data)
273
                    );
274
                }
275 View Code Duplication
                if ($method === "\x00\x14") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
276
                    return new Method\QueueBind(
277
                        $header['channel'],
278
                        Value\ShortValue::decode($data),
279
                        Value\ShortStringValue::decode($data),
280
                        Value\ShortStringValue::decode($data),
281
                        Value\ShortStringValue::decode($data),
282
                        Value\BooleanValue::decode($data),
283
                        Value\TableValue::decode($data)
284
                    );
285
                }
286
                if ($method === "\x00\x15") {
287
                    return new Method\QueueBindOk(
288
                        $header['channel']
289
                    );
290
                }
291 View Code Duplication
                if ($method === "\x00\x32") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
292
                    return new Method\QueueUnbind(
293
                        $header['channel'],
294
                        Value\ShortValue::decode($data),
295
                        Value\ShortStringValue::decode($data),
296
                        Value\ShortStringValue::decode($data),
297
                        Value\ShortStringValue::decode($data),
298
                        Value\TableValue::decode($data)
299
                    );
300
                }
301
                if ($method === "\x00\x33") {
302
                    return new Method\QueueUnbindOk(
303
                        $header['channel']
304
                    );
305
                }
306 View Code Duplication
                if ($method === "\x00\x1E") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
307
                    return new Method\QueuePurge(
308
                        $header['channel'],
309
                        Value\ShortValue::decode($data),
310
                        Value\ShortStringValue::decode($data),
311
                        Value\BooleanValue::decode($data)
312
                    );
313
                }
314
                if ($method === "\x00\x1F") {
315
                    return new Method\QueuePurgeOk(
316
                        $header['channel'],
317
                        Value\LongValue::decode($data)
318
                    );
319
                }
320 View Code Duplication
                if ($method === "\x00\x28") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
321
                    return new Method\QueueDelete(
322
                        $header['channel'],
323
                        Value\ShortValue::decode($data),
324
                        Value\ShortStringValue::decode($data),
325
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
326
                        (bool) $flags & 2,
327
                        (bool) $flags & 4
328
                    );
329
                }
330
                if ($method === "\x00\x29") {
331
                    return new Method\QueueDeleteOk(
332
                        $header['channel'],
333
                        Value\LongValue::decode($data)
334
                    );
335
                }
336
            }
337
338
            if ($class === "\x00\x3C") {
339
                if ($method === "\x00\x0A") {
340
                    return new Method\BasicQos(
341
                        $header['channel'],
342
                        Value\LongValue::decode($data),
343
                        Value\ShortValue::decode($data),
344
                        Value\BooleanValue::decode($data)
345
                    );
346
                }
347
                if ($method === "\x00\x0B") {
348
                    return new Method\BasicQosOk(
349
                        $header['channel']
350
                    );
351
                }
352 View Code Duplication
                if ($method === "\x00\x14") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
353
                    return new Method\BasicConsume(
354
                        $header['channel'],
355
                        Value\ShortValue::decode($data),
356
                        Value\ShortStringValue::decode($data),
357
                        Value\ShortStringValue::decode($data),
358
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
359
                        (bool) $flags & 2,
360
                        (bool) $flags & 4,
361
                        (bool) $flags & 8,
362
                        Value\TableValue::decode($data)
363
                    );
364
                }
365
                if ($method === "\x00\x15") {
366
                    return new Method\BasicConsumeOk(
367
                        $header['channel'],
368
                        Value\ShortStringValue::decode($data)
369
                    );
370
                }
371 View Code Duplication
                if ($method === "\x00\x1E") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
372
                    return new Method\BasicCancel(
373
                        $header['channel'],
374
                        Value\ShortStringValue::decode($data),
375
                        Value\BooleanValue::decode($data)
376
                    );
377
                }
378
                if ($method === "\x00\x1F") {
379
                    return new Method\BasicCancelOk(
380
                        $header['channel'],
381
                        Value\ShortStringValue::decode($data)
382
                    );
383
                }
384 View Code Duplication
                if ($method === "\x00\x28") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
385
                    return new Method\BasicPublish(
386
                        $header['channel'],
387
                        Value\ShortValue::decode($data),
388
                        Value\ShortStringValue::decode($data),
389
                        Value\ShortStringValue::decode($data),
390
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
391
                        (bool) $flags & 2
392
                    );
393
                }
394
                if ($method === "\x00\x32") {
395
                    return new Method\BasicReturn(
396
                        $header['channel'],
397
                        Value\ShortValue::decode($data),
398
                        Value\ShortStringValue::decode($data),
399
                        Value\ShortStringValue::decode($data),
400
                        Value\ShortStringValue::decode($data)
401
                    );
402
                }
403 View Code Duplication
                if ($method === "\x00\x3C") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
404
                    return new Method\BasicDeliver(
405
                        $header['channel'],
406
                        Value\ShortStringValue::decode($data),
407
                        Value\LongLongValue::decode($data),
408
                        Value\BooleanValue::decode($data),
409
                        Value\ShortStringValue::decode($data),
410
                        Value\ShortStringValue::decode($data)
411
                    );
412
                }
413 View Code Duplication
                if ($method === "\x00\x46") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
414
                    return new Method\BasicGet(
415
                        $header['channel'],
416
                        Value\ShortValue::decode($data),
417
                        Value\ShortStringValue::decode($data),
418
                        Value\BooleanValue::decode($data)
419
                    );
420
                }
421 View Code Duplication
                if ($method === "\x00\x47") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
422
                    return new Method\BasicGetOk(
423
                        $header['channel'],
424
                        Value\LongLongValue::decode($data),
425
                        Value\BooleanValue::decode($data),
426
                        Value\ShortStringValue::decode($data),
427
                        Value\ShortStringValue::decode($data),
428
                        Value\LongValue::decode($data)
429
                    );
430
                }
431
                if ($method === "\x00\x48") {
432
                    return new Method\BasicGetEmpty(
433
                        $header['channel'],
434
                        Value\ShortStringValue::decode($data)
435
                    );
436
                }
437 View Code Duplication
                if ($method === "\x00\x50") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
438
                    return new Method\BasicAck(
439
                        $header['channel'],
440
                        Value\LongLongValue::decode($data),
441
                        Value\BooleanValue::decode($data)
442
                    );
443
                }
444 View Code Duplication
                if ($method === "\x00\x5A") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
445
                    return new Method\BasicReject(
446
                        $header['channel'],
447
                        Value\LongLongValue::decode($data),
448
                        Value\BooleanValue::decode($data)
449
                    );
450
                }
451
                if ($method === "\x00\x64") {
452
                    return new Method\BasicRecoverAsync(
453
                        $header['channel'],
454
                        Value\BooleanValue::decode($data)
455
                    );
456
                }
457
                if ($method === "\x00\x6E") {
458
                    return new Method\BasicRecover(
459
                        $header['channel'],
460
                        Value\BooleanValue::decode($data)
461
                    );
462
                }
463
                if ($method === "\x00\x6F") {
464
                    return new Method\BasicRecoverOk(
465
                        $header['channel']
466
                    );
467
                }
468
                if ($method === "\x00\x78") {
469
                    return new Method\BasicNack(
470
                        $header['channel'],
471
                        Value\LongLongValue::decode($data),
472
                        (bool) ($flags = Value\OctetValue::decode($data)) & 1,
473
                        (bool) $flags & 2
474
                    );
475
                }
476
            }
477
478
            if ($class === "\x00\x5A") {
479
                if ($method === "\x00\x0A") {
480
                    return new Method\TxSelect(
481
                        $header['channel']
482
                    );
483
                }
484
                if ($method === "\x00\x0B") {
485
                    return new Method\TxSelectOk(
486
                        $header['channel']
487
                    );
488
                }
489
                if ($method === "\x00\x14") {
490
                    return new Method\TxCommit(
491
                        $header['channel']
492
                    );
493
                }
494
                if ($method === "\x00\x15") {
495
                    return new Method\TxCommitOk(
496
                        $header['channel']
497
                    );
498
                }
499
                if ($method === "\x00\x1E") {
500
                    return new Method\TxRollback(
501
                        $header['channel']
502
                    );
503
                }
504
                if ($method === "\x00\x1F") {
505
                    return new Method\TxRollbackOk(
506
                        $header['channel']
507
                    );
508
                }
509
            }
510
511
            if ($class === "\x00\x55") {
512
                if ($method === "\x00\x0A") {
513
                    return new Method\ConfirmSelect(
514
                        $header['channel'],
515
                        Value\BooleanValue::decode($data)
516
                    );
517
                }
518
                if ($method === "\x00\x0B") {
519
                    return new Method\ConfirmSelectOk(
520
                        $header['channel']
521
                    );
522
                }
523
            }
524
525
            throw new \InvalidArgumentException(sprintf(
526
                'Invalid method received %d:%d',
527
                Binary::unpackbe('s', $class),
528
                Binary::unpackbe('s', $method)
529
            ));
530
        } elseif ($header['type'] === 2) {
531
            $parameters = unpack('nclass/nweight/Jsize/nflags', $data->read(14));
532
            $flags = $parameters['flags'];
533
            $properties = [];
534
            if ($flags & 32768) {
535
                $properties['content-type'] = Value\ShortStringValue::decode($data);
536
            }
537
538
            if ($flags & 16384) {
539
                $properties['content-encoding'] = Value\ShortStringValue::decode($data);
540
            }
541
542
            if ($flags & 8192) {
543
                $properties['headers'] = Value\TableValue::decode($data);
544
            }
545
546
            if ($flags & 4096) {
547
                $properties['delivery-mode'] = Value\OctetValue::decode($data);
548
            }
549
550
            if ($flags & 2048) {
551
                $properties['priority'] = Value\OctetValue::decode($data);
552
            }
553
554
            if ($flags & 1024) {
555
                $properties['correlation-id'] = Value\ShortStringValue::decode($data);
556
            }
557
558
            if ($flags & 512) {
559
                $properties['reply-to'] = Value\ShortStringValue::decode($data);
560
            }
561
562
            if ($flags & 256) {
563
                $properties['expiration'] = Value\ShortStringValue::decode($data);
564
            }
565
566
            if ($flags & 128) {
567
                $properties['message-id'] = Value\ShortStringValue::decode($data);
568
            }
569
570
            if ($flags & 64) {
571
                $properties['timestamp'] = Value\LongLongValue::decode($data);
572
            }
573
574
            if ($flags & 32) {
575
                $properties['type'] = Value\ShortStringValue::decode($data);
576
            }
577
578
            if ($flags & 16) {
579
                $properties['user-id'] = Value\ShortStringValue::decode($data);
580
            }
581
582
            if ($flags & 8) {
583
                $properties['app-id'] = Value\ShortStringValue::decode($data);
584
            }
585
586
            if ($flags & 4) {
587
                $properties['reserved'] = Value\ShortStringValue::decode($data);
588
            }
589
590
            return new Header(
591
                $header['channel'],
592
                $parameters['class'],
593
                $parameters['weight'],
594
                $parameters['size'],
595
                $properties
596
            );
597
        } elseif ($header['type'] === 3) {
598
            return new Content($header['channel'], $data->read($header['size']));
599
        } elseif ($header['type'] === 8) {
600
            return new Heartbeat($header['channel']);
601
        }
602
603
        throw new \InvalidArgumentException(sprintf('Invalid frame type %d', $header['type']));
604
    }
605
}
606