Code Duplication    Length = 22-22 lines in 2 locations

src/Entity/ExchangeEntity.php 1 location

@@ 104-125 (lines=22) @@
101
    /**
102
     * Create the Queue
103
     */
104
    public function create()
105
    {
106
        try {
107
            $this->getChannel()
108
                ->exchange_declare(
109
                    $this->attributes['name'],
110
                    $this->attributes['exchange_type'],
111
                    $this->attributes['passive'],
112
                    $this->attributes['durable'],
113
                    $this->attributes['auto_delete'],
114
                    $this->attributes['internal'],
115
                    $this->attributes['nowait']
116
                );
117
        } catch (AMQPProtocolChannelException $e) {
118
            // 406 is a soft error triggered for precondition failure (when redeclaring with different parameters)
119
            if (true === $this->attributes['throw_exception_on_redeclare'] || $e->amqp_reply_code !== 406) {
120
                throw $e;
121
            }
122
            // a failure trigger channels closing process
123
            $this->getConnection()->reconnect();
124
        }
125
    }
126
127
    /**
128
     * @throws AMQPProtocolChannelException

src/Entity/QueueEntity.php 1 location

@@ 162-183 (lines=22) @@
159
    /**
160
     * Create the Queue
161
     */
162
    public function create()
163
    {
164
        try {
165
            $this->getChannel()
166
                ->queue_declare(
167
                    $this->attributes['name'],
168
                    $this->attributes['passive'],
169
                    $this->attributes['durable'],
170
                    $this->attributes['exclusive'],
171
                    $this->attributes['auto_delete'],
172
                    $this->attributes['internal'],
173
                    $this->attributes['nowait']
174
                );
175
        } catch (AMQPProtocolChannelException $e) {
176
            // 406 is a soft error triggered for precondition failure (when redeclaring with different parameters)
177
            if (true === $this->attributes['throw_exception_on_redeclare'] || $e->amqp_reply_code !== 406) {
178
                throw $e;
179
            }
180
            // a failure trigger channels closing process
181
            $this->getConnection()->reconnect();
182
        }
183
    }
184
185
    public function bind()
186
    {