Code Duplication    Length = 22-22 lines in 2 locations

src/Entity/ExchangeEntity.php 1 location

@@ 125-146 (lines=22) @@
122
    /**
123
     * Create the Queue
124
     */
125
    public function create()
126
    {
127
        try {
128
            $this->getChannel()
129
                ->exchange_declare(
130
                    $this->attributes['name'],
131
                    $this->attributes['exchange_type'],
132
                    $this->attributes['passive'],
133
                    $this->attributes['durable'],
134
                    $this->attributes['auto_delete'],
135
                    $this->attributes['internal'],
136
                    $this->attributes['nowait']
137
                );
138
        } catch (AMQPProtocolChannelException $e) {
139
            // 406 is a soft error triggered for precondition failure (when redeclaring with different parameters)
140
            if (true === $this->attributes['throw_exception_on_redeclare'] || $e->amqp_reply_code !== 406) {
141
                throw $e;
142
            }
143
            // a failure trigger channels closing process
144
            $this->getConnection()->reconnect();
145
        }
146
    }
147
148
    /**
149
     * @throws AMQPProtocolChannelException

src/Entity/QueueEntity.php 1 location

@@ 184-205 (lines=22) @@
181
    /**
182
     * Create the Queue
183
     */
184
    public function create()
185
    {
186
        try {
187
            $this->getChannel()
188
                ->queue_declare(
189
                    $this->attributes['name'],
190
                    $this->attributes['passive'],
191
                    $this->attributes['durable'],
192
                    $this->attributes['exclusive'],
193
                    $this->attributes['auto_delete'],
194
                    $this->attributes['internal'],
195
                    $this->attributes['nowait']
196
                );
197
        } catch (AMQPProtocolChannelException $e) {
198
            // 406 is a soft error triggered for precondition failure (when redeclaring with different parameters)
199
            if (true === $this->attributes['throw_exception_on_redeclare'] || $e->amqp_reply_code !== 406) {
200
                throw $e;
201
            }
202
            // a failure trigger channels closing process
203
            $this->reconnect();
204
        }
205
    }
206
207
    public function bind()
208
    {