clients[$client->getId()] = $client; } /** * Get client by id * * @return mixed * * @since 1.0.0 */ public function get($id) { return $this->clients[$id] ?? new NullClientConnection($id, null); } /** * Get client by socket * * @param mixed $socket Socket * * @return mixed * * @since 1.0.0 */ public function getBySocket($socket) { foreach ($this->clients as $client) { if ($client->getSocket() === $socket) { return $client; } } return new NullClientConnection(new NullAccount(), null); } /** * Remove client by id * * @param mixed $id Client id * * @return bool * * @since 1.0.0 */ public function remove($id) : bool { if (isset($this->clients[$id])) { unset($this->clients[$id]); return true; } return false; } }