original_string: public static function getPayload(string $packet)
      {
          $packet = trim($packet);
          $start = strpos($packet, '[');
  
          if ($start === false || substr($packet, -1) !== ']') {
              return null;
          }
  
          $data = substr($packet, $start, strlen($packet) - $start);
          $data = json_decode($data, true);
  
          if (is_null($data)) {
              return null;
          }
  
          return [
              'event' => $data[0],
              'data' => $data[1] ?? null,
          ];
      }
code: public static function getPayload(string $packet)
      {
          $packet = trim($packet);
          $start = strpos($packet, '[');
  
          if ($start === false || substr($packet, -1) !== ']') {
              return null;
          }
  
          $data = substr($packet, $start, strlen($packet) - $start);
          $data = json_decode($data, true);
  
          if (is_null($data)) {
              return null;
          }
  
          return [
              'event' => $data[0],
              'data' => $data[1] ?? null,
          ];
      }
code_tokens: public static function getPayload ( string $ packet ) { $ packet = trim ( $ packet ) ; $ start = strpos ( $ packet , '[' ) ; if ( $ start === false || substr ( $ packet , - 1 ) !== ']' ) { return null ; } $ data = substr ( $ packet , $ start , strlen ( $ packet ) - $ start ) ; $ data = json_decode ( $ data , true ) ; if ( is_null ( $ data ) ) { return null ; } return [ 'event' => $ data [ 0 ] , 'data' => $ data [ 1 ] ?? null , ] ; }
docstring: Get data packet from a raw payload.
  
  @param string $packet
  
  @return array|null
docstring_tokens: Get data packet from a raw payload .