Completed
Push — master ( 4447aa...e37fbd )
by Vasily
09:14 queued 04:58
created

FrameSerializerTrait::serialize()   F

Complexity

Conditions 66
Paths 16435

Size

Total Lines 373
Code Lines 266

Duplication

Lines 196
Ratio 52.55 %

Importance

Changes 0
Metric Value
cc 66
eloc 266
nc 16435
nop 1
dl 196
loc 373
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Serializer;
4
5
use PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException;
6
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Access;
7
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Basic;
8
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\BodyFrame;
9
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Channel;
10
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Confirm;
11
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Connection;
12
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Exchange;
13
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\HeartbeatFrame;
14
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\OutgoingFrame;
15
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Queue;
16
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Tx;
17
18
/**
19
 * Class FrameSerializerTrait
20
 *
21
 * @property TableInterface tableSerializer
22
 * @author Aleksey I. Kuleshov YOU GLOBAL LIMITED
23
 * @package PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Serializer
24
 */
25
trait FrameSerializerTrait
26
{
27
    /**
28
     * @param OutgoingFrame $frame
29
     * @return string
30
     * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
31
     * @throws \InvalidArgumentException
32
     */
33
    public function serialize(OutgoingFrame $frame)
34
    {
35
        if ($frame instanceof HeartbeatFrame) {
36
            return "\x08\x00\x00\x00\x00\x00\x00\xce";
37
        }
38
        if ($frame instanceof BodyFrame) {
39
            return "\x03" . \pack('nN', $frame->frameChannelId, \strlen($frame->content)) . $frame->content . "\xce";
40
        }
41
        if ($frame instanceof Connection\ConnectionStartOkFrame) {
42
            $payload = "\x00\x0a\x00\x0b"
43
                . $this->tableSerializer->serialize($frame->clientProperties)
44
                . $this->serializeShortString($frame->mechanism)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
45
                . $this->serializeLongString($frame->response)
0 ignored issues
show
Bug introduced by
The method serializeLongString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
46
                . $this->serializeShortString($frame->locale);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
47
48
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
49
        }
50
        if ($frame instanceof Connection\ConnectionSecureOkFrame) {
51
            $payload = "\x00\x0a\x00\x15"
52
                . $this->serializeLongString($frame->response);
0 ignored issues
show
Bug introduced by
The method serializeLongString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
53
54
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
55
        }
56
        if ($frame instanceof Connection\ConnectionTuneOkFrame) {
57
            $payload = "\x00\x0a\x00\x1f"
58
                . \pack('nNn', $frame->channelMax, $frame->frameMax, $frame->heartbeat);
59
60
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
61
        }
62
        if ($frame instanceof Connection\ConnectionOpenFrame) {
63
            $payload = "\x00\x0a\x00\x28"
64
                . $this->serializeShortString($frame->virtualHost)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
65
                . $this->serializeShortString($frame->capabilities)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
66
                . ($frame->insist ? "\x01" : "\x00");
67
68
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
69
        }
70
        if ($frame instanceof Connection\ConnectionCloseFrame) {
71
            $payload = "\x00\x0a\x00\x32"
72
                . \pack('n', $frame->replyCode)
73
                . $this->serializeShortString($frame->replyText)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
74
                . \pack('nn', $frame->classId, $frame->methodId);
75
76
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
77
        }
78
        if ($frame instanceof Connection\ConnectionCloseOkFrame) {
79
            return "\x01" . \pack('n', $frame->frameChannelId) . "\x00\x00\x00\x04\x00\x0a\x00\x33\xce";
80
        }
81
        if ($frame instanceof Channel\ChannelOpenFrame) {
82
            $payload = "\x00\x14\x00\x0a"
83
                . $this->serializeShortString($frame->outOfBand);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
84
85
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
86
        }
87 View Code Duplication
        if ($frame instanceof Channel\ChannelFlowFrame) {
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
            $payload = "\x00\x14\x00\x14"
89
                . ($frame->active ? "\x01" : "\x00");
90
91
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
92
        }
93 View Code Duplication
        if ($frame instanceof Channel\ChannelFlowOkFrame) {
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...
94
            $payload = "\x00\x14\x00\x15"
95
                . ($frame->active ? "\x01" : "\x00");
96
97
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
98
        }
99
        if ($frame instanceof Channel\ChannelCloseFrame) {
100
            $payload = "\x00\x14\x00\x28"
101
                . \pack('n', $frame->replyCode)
102
                . $this->serializeShortString($frame->replyText)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
103
                . \pack('nn', $frame->classId, $frame->methodId);
104
105
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
106
        }
107
        if ($frame instanceof Channel\ChannelCloseOkFrame) {
108
            return "\x01" . \pack('n', $frame->frameChannelId) . "\x00\x00\x00\x04\x00\x14\x00\x29\xce";
109
        }
110
        if ($frame instanceof Access\AccessRequestFrame) {
111
            $payload = "\x00\x1e\x00\x0a"
112
                . $this->serializeShortString($frame->realm)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
113
                . \chr(
114
                    $frame->exclusive
115
                    | $frame->passive << 1
116
                    | $frame->active << 2
117
                    | $frame->write << 3
118
                    | $frame->read << 4
119
                );
120
121
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
122
        }
123 View Code Duplication
        if ($frame instanceof Exchange\ExchangeDeclareFrame) {
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...
124
            $payload = "\x00\x28\x00\x0a"
125
                . \pack('n', $frame->reserved1)
126
                . $this->serializeShortString($frame->exchange)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
127
                . $this->serializeShortString($frame->type)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
128
                . \chr(
129
                    $frame->passive
130
                    | $frame->durable << 1
131
                    | $frame->autoDelete << 2
132
                    | $frame->internal << 3
133
                    | $frame->nowait << 4
134
                )
135
                . $this->tableSerializer->serialize($frame->arguments);
136
137
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
138
        }
139 View Code Duplication
        if ($frame instanceof Exchange\ExchangeDeleteFrame) {
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...
140
            $payload = "\x00\x28\x00\x14"
141
                . \pack('n', $frame->reserved1)
142
                . $this->serializeShortString($frame->exchange)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
143
                . \chr(
144
                    $frame->ifUnused
145
                    | $frame->nowait << 1
146
                );
147
148
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
149
        }
150 View Code Duplication
        if ($frame instanceof Exchange\ExchangeBindFrame) {
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...
151
            $payload = "\x00\x28\x00\x1e"
152
                . \pack('n', $frame->reserved1)
153
                . $this->serializeShortString($frame->destination)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
154
                . $this->serializeShortString($frame->source)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
155
                . $this->serializeShortString($frame->routingKey)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
156
                . ($frame->nowait ? "\x01" : "\x00")
157
                . $this->tableSerializer->serialize($frame->arguments);
158
159
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
160
        }
161 View Code Duplication
        if ($frame instanceof Exchange\ExchangeUnbindFrame) {
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...
162
            $payload = "\x00\x28\x00\x28"
163
                . \pack('n', $frame->reserved1)
164
                . $this->serializeShortString($frame->destination)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
165
                . $this->serializeShortString($frame->source)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
166
                . $this->serializeShortString($frame->routingKey)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
167
                . ($frame->nowait ? "\x01" : "\x00")
168
                . $this->tableSerializer->serialize($frame->arguments);
169
170
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
171
        }
172 View Code Duplication
        if ($frame instanceof Queue\QueueDeclareFrame) {
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...
173
            $payload = "\x00\x32\x00\x0a"
174
                . \pack('n', $frame->reserved1)
175
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
176
                . \chr(
177
                    $frame->passive
178
                    | $frame->durable << 1
179
                    | $frame->exclusive << 2
180
                    | $frame->autoDelete << 3
181
                    | $frame->nowait << 4
182
                )
183
                . $this->tableSerializer->serialize($frame->arguments);
184
185
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
186
        }
187 View Code Duplication
        if ($frame instanceof Queue\QueueBindFrame) {
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...
188
            $payload = "\x00\x32\x00\x14"
189
                . \pack('n', $frame->reserved1)
190
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
191
                . $this->serializeShortString($frame->exchange)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
192
                . $this->serializeShortString($frame->routingKey)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
193
                . ($frame->nowait ? "\x01" : "\x00")
194
                . $this->tableSerializer->serialize($frame->arguments);
195
196
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
197
        }
198 View Code Duplication
        if ($frame instanceof Queue\QueuePurgeFrame) {
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...
199
            $payload = "\x00\x32\x00\x1e"
200
                . \pack('n', $frame->reserved1)
201
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
202
                . ($frame->nowait ? "\x01" : "\x00");
203
204
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
205
        }
206 View Code Duplication
        if ($frame instanceof Queue\QueueDeleteFrame) {
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...
207
            $payload = "\x00\x32\x00\x28"
208
                . \pack('n', $frame->reserved1)
209
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
210
                . \chr(
211
                    $frame->ifUnused
212
                    | $frame->ifEmpty << 1
213
                    | $frame->nowait << 2
214
                );
215
216
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
217
        }
218 View Code Duplication
        if ($frame instanceof Queue\QueueUnbindFrame) {
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...
219
            $payload = "\x00\x32\x00\x32"
220
                . \pack('n', $frame->reserved1)
221
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
222
                . $this->serializeShortString($frame->exchange)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
223
                . $this->serializeShortString($frame->routingKey)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
224
                . $this->tableSerializer->serialize($frame->arguments);
225
226
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
227
        }
228
        if ($frame instanceof Basic\BasicHeaderFrame) {
229
            $flags = 0;
230
            $properties = '';
231
232
            if (null !== $frame->contentType) {
233
                $flags |= 32768;
234
                $properties .= $this->serializeShortString($frame->contentType);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
235
            }
236
237
            if (null !== $frame->contentEncoding) {
238
                $flags |= 16384;
239
                $properties .= $this->serializeShortString($frame->contentEncoding);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
240
            }
241
242
            if (null !== $frame->headers) {
243
                $flags |= 8192;
244
                $properties .= $this->tableSerializer->serialize($frame->headers);
245
            }
246
247 View Code Duplication
            if (null !== $frame->deliveryMode) {
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...
248
                $flags |= 4096;
249
                $properties .= \pack('c', $frame->deliveryMode);
250
            }
251
252 View Code Duplication
            if (null !== $frame->priority) {
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...
253
                $flags |= 2048;
254
                $properties .= \pack('c', $frame->priority);
255
            }
256
257
            if (null !== $frame->correlationId) {
258
                $flags |= 1024;
259
                $properties .= $this->serializeShortString($frame->correlationId);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
260
            }
261
262
            if (null !== $frame->replyTo) {
263
                $flags |= 512;
264
                $properties .= $this->serializeShortString($frame->replyTo);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
265
            }
266
267
            if (null !== $frame->expiration) {
268
                $flags |= 256;
269
                $properties .= $this->serializeShortString($frame->expiration);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
270
            }
271
272
            if (null !== $frame->messageId) {
273
                $flags |= 128;
274
                $properties .= $this->serializeShortString($frame->messageId);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
275
            }
276
277
            if (null !== $frame->timestamp) {
278
                $flags |= 64;
279
                $properties .= \pack('J', $frame->timestamp);
280
            }
281
282
            if (null !== $frame->type) {
283
                $flags |= 32;
284
                $properties .= $this->serializeShortString($frame->type);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
285
            }
286
287
            if (null !== $frame->userId) {
288
                $flags |= 16;
289
                $properties .= $this->serializeShortString($frame->userId);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
290
            }
291
292
            if (null !== $frame->appId) {
293
                $flags |= 8;
294
                $properties .= $this->serializeShortString($frame->appId);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
295
            }
296
297
            if (null !== $frame->clusterId) {
298
                $flags |= 4;
299
                $properties .= $this->serializeShortString($frame->clusterId);
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
300
            }
301
302
            $payload = "\x00\x3c\x00\x00"
303
                . \pack('Jn', $frame->contentLength, $flags)
304
                . $properties;
305
306
            return "\x02" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
307
        }
308
        if ($frame instanceof Basic\BasicQosFrame) {
309
            $payload = "\x00\x3c\x00\x0a"
310
                . \pack('Nn', $frame->prefetchSize, $frame->prefetchCount)
311
                . ($frame->global ? "\x01" : "\x00");
312
313
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
314
        }
315 View Code Duplication
        if ($frame instanceof Basic\BasicConsumeFrame) {
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...
316
            $payload = "\x00\x3c\x00\x14"
317
                . \pack('n', $frame->reserved1)
318
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
319
                . $this->serializeShortString($frame->consumerTag)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
320
                . \chr(
321
                    $frame->noLocal
322
                    | $frame->noAck << 1
323
                    | $frame->exclusive << 2
324
                    | $frame->nowait << 3
325
                )
326
                . $this->tableSerializer->serialize($frame->arguments);
327
328
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
329
        }
330
        if ($frame instanceof Basic\BasicCancelFrame) {
331
            $payload = "\x00\x3c\x00\x1e"
332
                . $this->serializeShortString($frame->consumerTag)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
333
                . ($frame->nowait ? "\x01" : "\x00");
334
335
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
336
        }
337 View Code Duplication
        if ($frame instanceof Basic\BasicPublishFrame) {
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...
338
            $payload = "\x00\x3c\x00\x28"
339
                . \pack('n', $frame->reserved1)
340
                . $this->serializeShortString($frame->exchange)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
341
                . $this->serializeShortString($frame->routingKey)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
342
                . \chr(
343
                    $frame->mandatory
344
                    | $frame->immediate << 1
345
                );
346
347
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
348
        }
349 View Code Duplication
        if ($frame instanceof Basic\BasicGetFrame) {
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...
350
            $payload = "\x00\x3c\x00\x46"
351
                . \pack('n', $frame->reserved1)
352
                . $this->serializeShortString($frame->queue)
0 ignored issues
show
Bug introduced by
The method serializeShortString() does not exist on PHPDaemon\Clients\AMQP\D...er\FrameSerializerTrait. Did you maybe mean serialize()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
353
                . ($frame->noAck ? "\x01" : "\x00");
354
355
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
356
        }
357 View Code Duplication
        if ($frame instanceof Basic\BasicAckFrame) {
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...
358
            $payload = "\x00\x3c\x00\x50"
359
                . \pack('J', $frame->deliveryTag)
360
                . ($frame->multiple ? "\x01" : "\x00");
361
362
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
363
        }
364 View Code Duplication
        if ($frame instanceof Basic\BasicRejectFrame) {
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...
365
            $payload = "\x00\x3c\x00\x5a"
366
                . \pack('J', $frame->deliveryTag)
367
                . ($frame->requeue ? "\x01" : "\x00");
368
369
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
370
        }
371 View Code Duplication
        if ($frame instanceof Basic\BasicRecoverFrame) {
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
            $payload = "\x00\x3c\x00\x6e"
373
                . ($frame->requeue ? "\x01" : "\x00");
374
375
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
376
        }
377 View Code Duplication
        if ($frame instanceof Basic\BasicNackFrame) {
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...
378
            $payload = "\x00\x3c\x00\x78"
379
                . \pack('J', $frame->deliveryTag)
380
                . \chr(
381
                    $frame->multiple
382
                    | $frame->requeue << 1
383
                );
384
385
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
386
        }
387
        if ($frame instanceof Tx\TxSelectFrame) {
388
            return "\x01" . \pack('n', $frame->frameChannelId) . "\x00\x00\x00\x04\x00\x5a\x00\x0a\xce";
389
        }
390
        if ($frame instanceof Tx\TxCommitFrame) {
391
            return "\x01" . \pack('n', $frame->frameChannelId) . "\x00\x00\x00\x04\x00\x5a\x00\x14\xce";
392
        }
393
        if ($frame instanceof Tx\TxRollbackFrame) {
394
            return "\x01" . \pack('n', $frame->frameChannelId) . "\x00\x00\x00\x04\x00\x5a\x00\x1e\xce";
395
        }
396 View Code Duplication
        if ($frame instanceof Confirm\ConfirmSelectFrame) {
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...
397
            $payload = "\x00\x55\x00\x0a"
398
                . ($frame->nowait ? "\x01" : "\x00");
399
400
            return "\x01" . \pack('nN', $frame->frameChannelId, \strlen($payload)) . $payload . "\xce";
401
        }
402
403
        throw new AMQPProtocolException(
404
            sprintf('Frame %s not implemented yet', get_class($frame)));
405
    }
406
}
407