/** * @param \jegarn\packet\Packet $packet * @return null|static */ public static function getPacketFromPacket(Packet $packet) { if ($packet && $packet->getType()) { $self = new static(); if ($packet->getType() == $self->getType()) { $self->setPacket($packet); return $self; } } return null; }
/** * @param Packet $packet * * @return Packet */ public function dispatch(Packet $packet) : Packet { $packetType = $packet->getType(); if (!isset($this->handlers[$packetType])) { return $packet; } $this->doDispatch($this->getHandlers($packetType), $packet); return $packet; }