Code Duplication    Length = 13-15 lines in 2 locations

PHPDaemon/Clients/Asterisk/Connection.php 2 locations

@@ 245-257 (lines=13) @@
242
                                $this->event('connected');
243
                            }
244
                        }
245
                    } else {
246
                        $this->state = self::CONN_STATE_HANDSHAKED_ERROR;
247
248
                        Daemon::$process->log(
249
                            __METHOD__ . ': Authentication failed. Connection to ' .
250
                            parse_url($this->addr, PHP_URL_HOST) . ' failed.'
251
                        );
252
253
                        if ($this->onConnected) {
254
                            $this->connected = false;
255
                            $this->onConnected->executeAll($this);
256
                            $this->onConnected = null;
257
                        }
258
259
                        $this->finish();
260
                    }
@@ 227-241 (lines=15) @@
224
                                $func = $this->onChallenge;
225
                                $func($this, $packet['challenge']);
226
                            }
227
                        } else {
228
                            if ($packet['message'] === 'authentication accepted') {
229
                                $this->state = self::CONN_STATE_HANDSHAKED_OK;
230
231
                                Daemon::$process->log(
232
                                    __METHOD__ . ': Authentication ok. Connected to ' .
233
                                    parse_url($this->addr, PHP_URL_HOST)
234
                                );
235
236
                                if ($this->onConnected) {
237
                                    $this->connected = true;
238
                                    $this->onConnected->executeAll($this);
239
                                    $this->onConnected = null;
240
                                }
241
242
                                $this->event('connected');
243
                            }
244
                        }