Code Duplication    Length = 14-15 lines in 3 locations

PHPDaemon/Clients/MySQL/Connection.php 1 location

@@ 198-211 (lines=14) @@
195
     * @callback $cb ( Connection $conn, boolean $success )
196
     * @return void
197
     */
198
    public function onConnected($cb)
199
    {
200
        if ($this->phase === self::PHASE_AUTH_ERR) {
201
            $cb($this, false);
202
        } elseif ($this->phase === self::PHASE_HANDSHAKED) {
203
            $cb($this, true);
204
        } else {
205
            if (!$this->onConnected) {
206
                $this->onConnected = new StackCallbacks();
207
            }
208
            $this->onConnected->push($cb);
209
        }
210
    }
211
212
    /**
213
     * Called when the connection is handshaked (at low-level), and peer is ready to recv. data
214
     * @return void

PHPDaemon/Clients/Asterisk/Connection.php 1 location

@@ 127-141 (lines=15) @@
124
     * @param  callable Callback
125
     * @return void
126
     */
127
    public function onConnected($cb)
128
    {
129
        if ($this->state === self::CONN_STATE_HANDSHAKED_ERROR) {
130
            $cb($this);
131
        } elseif ($this->state === self::CONN_STATE_HANDSHAKED_OK) {
132
            $cb($this);
133
        } else {
134
            if (!$this->onConnected) {
135
                $this->onConnected = new StackCallbacks();
136
            }
137
138
            $this->onConnected->push($cb);
139
        }
140
    }
141
142
    /**
143
     * Called when the connection is handshaked (at low-level), and peer is ready to recv. data
144
     * @return void

PHPDaemon/Clients/PostgreSQL/Connection.php 1 location

@@ 157-170 (lines=14) @@
154
     * @callback $cb ( )
155
     * @return void
156
     */
157
    public function onConnected($cb)
158
    {
159
        if ($this->state === self::STATE_AUTH_ERROR) {
160
            $cb($this, false);
161
        } elseif ($this->state === self::STATE_AUTH_OK) {
162
            $cb($this, true);
163
        } else {
164
            if (!$this->onConnected) {
165
                $this->onConnected = new StackCallbacks();
166
            }
167
            $this->onConnected->push($cb);
168
        }
169
    }
170
171
    /**
172
     * Converts binary string to integer
173
     * @param  string $str Binary string