Code Duplication    Length = 14-15 lines in 3 locations

PHPDaemon/Clients/Asterisk/Connection.php 1 location

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

PHPDaemon/Clients/PostgreSQL/Connection.php 1 location

@@ 136-149 (lines=14) @@
133
	 * @callback $cb ( )
134
	 * @return void
135
	 */
136
	public function onConnected($cb) {
137
		if ($this->state === self::STATE_AUTH_ERROR) {
138
			call_user_func($cb, $this, false);
139
		}
140
		elseif ($this->state === self::STATE_AUTH_OK) {
141
			call_user_func($cb, $this, true);
142
		}
143
		else {
144
			if (!$this->onConnected) {
145
				$this->onConnected = new StackCallbacks();
146
			}
147
			$this->onConnected->push($cb);
148
		}
149
	}
150
151
	/**
152
	 * Converts binary string to integer

PHPDaemon/Clients/MySQL/Connection.php 1 location

@@ 197-210 (lines=14) @@
194
	 * @callback $cb ( Connection $conn, boolean $success )
195
	 * @return void
196
	 */
197
	public function onConnected($cb) {
198
		if ($this->phase === self::PHASE_AUTH_ERR) {
199
			call_user_func($cb, $this, false);
200
		}
201
		elseif ($this->phase === self::PHASE_HANDSHAKED) {
202
			call_user_func($cb, $this, true);
203
		}
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