<commit_before><?php

declare(strict_types=1);

namespace Gitlab\HttpClient\Message;

final class QueryStringBuilder
{
    /**
     * Encode a query as a query string according to RFC 3986. Indexed arrays are encoded using
     * empty squared brackets ([]) unlike http_build_query.
     *
     * @param mixed $query
     *
     * @return string
     */
    public static function build($query)
    {
        if (!is_array($query)) {
            return self::rawurlencode($query);
        }
        $query = array_filter($query, function ($value) {
            return null !== $value;
        });

        return implode('&', array_map(function ($value, $key) {
            return self::encode($value, $key);
        }, $query, array_keys($query)));
    }

    /**
     * Encode a value.
     *
     * @param mixed  $query
     * @param string $prefix<commit_msg>Marked query string builder as internal<commit_after><?php

declare(strict_types=1);

namespace Gitlab\HttpClient\Message;

/**
 * @internal
 */
final class QueryStringBuilder
{
    /**
     * Encode a query as a query string according to RFC 3986. Indexed arrays are encoded using
     * empty squared brackets ([]) unlike http_build_query.
     *
     * @param mixed $query
     *
     * @return string
     */
    public static function build($query)
    {
        if (!is_array($query)) {
            return self::rawurlencode($query);
        }
        $query = array_filter($query, function ($value) {
            return null !== $value;
        });

        return implode('&', array_map(function ($value, $key) {
            return self::encode($value, $key);
        }, $query, array_keys($query)));
    }

    /**
     * Encode a value.
     *
     * @param mixed  $query
     * @param string $prefix
{'fraction_non_alphanumeric': 0.12915961646926113, 'fraction_numerical': 0.0056401579244218835, 'mean_word_length': 2.273062730627306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3396442', 'n_tokens_mistral': 525, 'n_tokens_neox': 506, 'n_words': 139}