public static function getTypeIdByClass($className)
    {
        if (null === self::$typesByClass) {
            self::$typesByClass = array_flip(self::$types);
        }

        if (!isset(self::$typesByClass[$className])) {
            throw new UnknownMessageException('Class not registered: '.$className.'.');
        }

        return self::$typesByClass[$className];
    }