original_string: public function encode(string $event, $data)
      {
          $packet = Packet::MESSAGE . Packet::EVENT;
          $shouldEncode = is_array($data) || is_object($data);
          $data = $shouldEncode ? json_encode($data) : $data;
          $format = $shouldEncode ? '["%s",%s]' : '["%s","%s"]';
  
          return $packet . sprintf($format, $event, $data);
      }
code: public function encode(string $event, $data)
      {
          $packet = Packet::MESSAGE . Packet::EVENT;
          $shouldEncode = is_array($data) || is_object($data);
          $data = $shouldEncode ? json_encode($data) : $data;
          $format = $shouldEncode ? '["%s",%s]' : '["%s","%s"]';
  
          return $packet . sprintf($format, $event, $data);
      }
code_tokens: public function encode ( string $ event , $ data ) { $ packet = Packet :: MESSAGE . Packet :: EVENT ; $ shouldEncode = is_array ( $ data ) || is_object ( $ data ) ; $ data = $ shouldEncode ? json_encode ( $ data ) : $ data ; $ format = $ shouldEncode ? '["%s",%s]' : '["%s","%s"]' ; return $ packet . sprintf ( $ format , $ event , $ data ) ; }
docstring: Encode output payload for websocket push.
  
  @param string $event
  @param mixed $data
  
  @return mixed
docstring_tokens: Encode output payload for websocket push .