<commit_before><?php

namespace Linio\Component\Util;

class Json
{
    /**
     * @param mixed $data
     * @return string
     * @throws \LogicException If encoding fails
     */
    public static function encode($data)
    {
        if (is_resource($data)) {
            throw new \InvalidArgumentException('Resource types cannot be encoded');
        }

        $result = json_encode($data);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \LogicException(self::getLastJsonError());
        }

        return $result;
    }

    /**
     * @param mixed $data
     * @return string
     * @throws \LogicException If decoding fails
     */
    public static function decode($data)
    {
        $result = json_decode($data, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \LogicException(self::getLastJsonError());
        }

        return $result;
    }

    /**
     * @return string
     */
    public static function getLastJsonError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_DEPTH:
                return 'Invalid JSON: Maximum stack depth exceeded';

            case JSON_ERROR_STATE_MISMATCH:
                return 'Invalid JSON: Underflow or modes mismatch';

            case JSON_ERROR_CTRL_CHAR:
                return 'Invalid JSON: Unexpected control character found';

            case JSON_ERROR_SYNTAX:
                return 'Invalid JSON: Syntax error';

            case JSON_ERROR_UTF8:
                return 'Invalid JSON: Malformed UTF-8 characters, possibly incorrectly encoded';

            default:
                return 'Invalid JSON: Unknown error';
        }
    }
}
<commit_msg>Fixed json decode returned type.<commit_after><?php

namespace Linio\Component\Util;

class Json
{
    /**
     * @param mixed $data
     * @return string
     * @throws \LogicException If encoding fails
     */
    public static function encode($data)
    {
        if (is_resource($data)) {
            throw new \InvalidArgumentException('Resource types cannot be encoded');
        }

        $result = json_encode($data);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \LogicException(self::getLastJsonError());
        }

        return $result;
    }

    /**
     * @param mixed $data
     * @return mixed
     * @throws \LogicException If decoding fails
     */
    public static function decode($data)
    {
        $result = json_decode($data, true);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \LogicException(self::getLastJsonError());
        }

        return $result;
    }

    /**
     * @return string
     */
    public static function getLastJsonError()
    {
        switch (json_last_error()) {
            case JSON_ERROR_DEPTH:
                return 'Invalid JSON: Maximum stack depth exceeded';

            case JSON_ERROR_STATE_MISMATCH:
                return 'Invalid JSON: Underflow or modes mismatch';

            case JSON_ERROR_CTRL_CHAR:
                return 'Invalid JSON: Unexpected control character found';

            case JSON_ERROR_SYNTAX:
                return 'Invalid JSON: Syntax error';

            case JSON_ERROR_UTF8:
                return 'Invalid JSON: Malformed UTF-8 characters, possibly incorrectly encoded';

            default:
                return 'Invalid JSON: Unknown error';
        }
    }
}

{'fraction_non_alphanumeric': 0.09284051222351572, 'fraction_numerical': 0.0011641443538998836, 'mean_word_length': 1.94263698630137, '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': '3544190', 'n_tokens_mistral': 939, 'n_tokens_neox': 882, 'n_words': 250}