Code Duplication    Length = 22-22 lines in 2 locations

src/Entity/ExchangeEntity.php 1 location

@@ 130-151 (lines=22) @@
127
    /**
128
     * @throws AMQPProtocolChannelException
129
     */
130
    public function bind()
131
    {
132
        if (!isset($this->attributes['bind']) || empty($this->attributes['bind'])) {
133
            return;
134
        }
135
        foreach ($this->attributes['bind'] as $bindItem) {
136
            try {
137
                $this->getChannel()
138
                    ->queue_bind(
139
                        $bindItem['queue'],
140
                        $this->attributes['name'],
141
                        $bindItem['routing_key']
142
                    );
143
            } catch (AMQPProtocolChannelException $e) {
144
                // 404 is the code for trying to bind to an non-existing entity
145
                if (true === $this->attributes['throw_exception_on_bind_fail'] || $e->amqp_reply_code !== 404) {
146
                    throw $e;
147
                }
148
                $this->getConnection()->reconnect();
149
            }
150
        }
151
    }
152
153
    /**
154
     * Delete the queue

src/Entity/QueueEntity.php 1 location

@@ 185-206 (lines=22) @@
182
        }
183
    }
184
185
    public function bind()
186
    {
187
        if (!isset($this->attributes['bind']) || empty($this->attributes['bind'])) {
188
            return;
189
        }
190
        foreach ($this->attributes['bind'] as $bindItem) {
191
            try {
192
                $this->getChannel()
193
                    ->queue_bind(
194
                        $this->attributes['name'],
195
                        $bindItem['exchange'],
196
                        $bindItem['routing_key']
197
                    );
198
            } catch (AMQPProtocolChannelException $e) {
199
                // 404 is the code for trying to bind to an non-existing entity
200
                if (true === $this->attributes['throw_exception_on_bind_fail'] || $e->amqp_reply_code !== 404) {
201
                    throw $e;
202
                }
203
                $this->getConnection()->reconnect();
204
            }
205
        }
206
    }
207
208
    /**
209
     * Delete the queue