lib/SteamCondenser/Servers/Packets/SteamPacketFactory.php
public static function getPacketFromData($rawData) {
        $header = ord($rawData[0]);
        $data = substr($rawData, 1);

        switch($header) {
            case SteamPacket::S2A_INFO_DETAILED_HEADER:
                return new S2AINFODETAILEDPacket($data);

            case SteamPacket::S2A_INFO2_HEADER:
                return new S2AINFO2Packet($data);

            case SteamPacket::S2A_PLAYER_HEADER:
                return new S2APLAYERPacket($data);

            case SteamPacket::S2A_RULES_HEADER:
                return new S2ARULESPacket($data);

            case SteamPacket::S2C_CHALLENGE_HEADER:
                return new S2CCHALLENGEPacket($data);

            case SteamPacket::M2A_SERVER_BATCH_HEADER:
                return new M2ASERVERBATCHPacket($data);

            case SteamPacket::RCON_GOLDSRC_CHALLENGE_HEADER:
            case SteamPacket::RCON_GOLDSRC_NO_CHALLENGE_HEADER:
            case SteamPacket::RCON_GOLDSRC_RESPONSE_HEADER:
                return new RCONGoldSrcResponse($data);

            default:
                throw new PacketFormatException('Unknown packet with header 0x' . dechex($header) . ' received.');
        }
    }
public static function getPacketFromData($rawData) {
        $header = ord($rawData[0]);
        $data = substr($rawData, 1);

        switch($header) {
            case SteamPacket::S2A_INFO_DETAILED_HEADER:
                return new S2AINFODETAILEDPacket($data);

            case SteamPacket::S2A_INFO2_HEADER:
                return new S2AINFO2Packet($data);

            case SteamPacket::S2A_PLAYER_HEADER:
                return new S2APLAYERPacket($data);

            case SteamPacket::S2A_RULES_HEADER:
                return new S2ARULESPacket($data);

            case SteamPacket::S2C_CHALLENGE_HEADER:
                return new S2CCHALLENGEPacket($data);

            case SteamPacket::M2A_SERVER_BATCH_HEADER:
                return new M2ASERVERBATCHPacket($data);

            case SteamPacket::RCON_GOLDSRC_CHALLENGE_HEADER:
            case SteamPacket::RCON_GOLDSRC_NO_CHALLENGE_HEADER:
            case SteamPacket::RCON_GOLDSRC_RESPONSE_HEADER:
                return new RCONGoldSrcResponse($data);

            default:
                throw new PacketFormatException('Unknown packet with header 0x' . dechex($header) . ' received.');
        }
    }
Creates a new packet object based on the header byte of the given raw
data

@param string $rawData The raw data of the packet
@throws PacketFormatException if the packet header is not recognized
@return SteamPacket The packet object generated from the packet data