original_string: private function handlePacket(Packet $packet)
      {
          switch ($packet->getPacketType()) {
              case Packet::TYPE_PUBLISH:
                  /* @var PublishRequestPacket $packet */
                  $message = new DefaultMessage(
                      $packet->getTopic(),
                      $packet->getPayload(),
                      $packet->getQosLevel(),
                      $packet->isRetained(),
                      $packet->isDuplicate()
                  );
  
                  $this->startFlow(new IncomingPublishFlow($message, $packet->getIdentifier()));
                  break;
              case Packet::TYPE_CONNACK:
              case Packet::TYPE_PINGRESP:
              case Packet::TYPE_SUBACK:
              case Packet::TYPE_UNSUBACK:
              case Packet::TYPE_PUBREL:
              case Packet::TYPE_PUBACK:
              case Packet::TYPE_PUBREC:
              case Packet::TYPE_PUBCOMP:
                  $flowFound = false;
                  foreach ($this->receivingFlows as $index => $flow) {
                      if ($flow->accept($packet)) {
                          $flowFound = true;
  
                          unset($this->receivingFlows[$index]);
                          $this->continueFlow($flow, $packet);
  
                          break;
                      }
                  }
  
                  if (!$flowFound) {
                      $this->emitWarning(
                          new \LogicException(sprintf('Received unexpected packet of type %d.', $packet->getPacketType()))
                      );
                  }
                  break;
              default:
                  $this->emitWarning(
                      new \LogicException(sprintf('Cannot handle packet of type %d.', $packet->getPacketType()))
                  );
          }
      }
code: private function handlePacket(Packet $packet)
      {
          switch ($packet->getPacketType()) {
              case Packet::TYPE_PUBLISH:
                  /* @var PublishRequestPacket $packet */
                  $message = new DefaultMessage(
                      $packet->getTopic(),
                      $packet->getPayload(),
                      $packet->getQosLevel(),
                      $packet->isRetained(),
                      $packet->isDuplicate()
                  );
  
                  $this->startFlow(new IncomingPublishFlow($message, $packet->getIdentifier()));
                  break;
              case Packet::TYPE_CONNACK:
              case Packet::TYPE_PINGRESP:
              case Packet::TYPE_SUBACK:
              case Packet::TYPE_UNSUBACK:
              case Packet::TYPE_PUBREL:
              case Packet::TYPE_PUBACK:
              case Packet::TYPE_PUBREC:
              case Packet::TYPE_PUBCOMP:
                  $flowFound = false;
                  foreach ($this->receivingFlows as $index => $flow) {
                      if ($flow->accept($packet)) {
                          $flowFound = true;
  
                          unset($this->receivingFlows[$index]);
                          $this->continueFlow($flow, $packet);
  
                          break;
                      }
                  }
  
                  if (!$flowFound) {
                      $this->emitWarning(
                          new \LogicException(sprintf('Received unexpected packet of type %d.', $packet->getPacketType()))
                      );
                  }
                  break;
              default:
                  $this->emitWarning(
                      new \LogicException(sprintf('Cannot handle packet of type %d.', $packet->getPacketType()))
                  );
          }
      }
code_tokens: private function handlePacket ( Packet $ packet ) { switch ( $ packet -> getPacketType ( ) ) { case Packet :: TYPE_PUBLISH : /* @var PublishRequestPacket $packet */ $ message = new DefaultMessage ( $ packet -> getTopic ( ) , $ packet -> getPayload ( ) , $ packet -> getQosLevel ( ) , $ packet -> isRetained ( ) , $ packet -> isDuplicate ( ) ) ; $ this -> startFlow ( new IncomingPublishFlow ( $ message , $ packet -> getIdentifier ( ) ) ) ; break ; case Packet :: TYPE_CONNACK : case Packet :: TYPE_PINGRESP : case Packet :: TYPE_SUBACK : case Packet :: TYPE_UNSUBACK : case Packet :: TYPE_PUBREL : case Packet :: TYPE_PUBACK : case Packet :: TYPE_PUBREC : case Packet :: TYPE_PUBCOMP : $ flowFound = false ; foreach ( $ this -> receivingFlows as $ index => $ flow ) { if ( $ flow -> accept ( $ packet ) ) { $ flowFound = true ; unset ( $ this -> receivingFlows [ $ index ] ) ; $ this -> continueFlow ( $ flow , $ packet ) ; break ; } } if ( ! $ flowFound ) { $ this -> emitWarning ( new \ LogicException ( sprintf ( 'Received unexpected packet of type %d.' , $ packet -> getPacketType ( ) ) ) ) ; } break ; default : $ this -> emitWarning ( new \ LogicException ( sprintf ( 'Cannot handle packet of type %d.' , $ packet -> getPacketType ( ) ) ) ) ; } }
docstring: Handles an incoming packet.
  
  @param Packet $packet
docstring_tokens: Handles an incoming packet .