/** * @param $callback * @throws Exceptions\SocketException * @return $this */ public function onError($callback) { // check callback if (!\is_callable($callback)) { throw SocketException::invalidCallbackFor(__METHOD__); } // register $this->onErrorCallbacks[] = $callback; return $this; }