<commit_before><?php

namespace League\Glide\Requests;

use Symfony\Component\HttpFoundation\Request;

class RequestFactory
{
    /**
     * Create a request instance.
     * @param  max     $args                 The request object or path/params combination.
     * @param  array   $defaultManipulations The default image manipulations.
     * @return Request The request object.
     */
    public static function create($args, $defaultManipulations = [])
    {
        if (isset($args[0]) and $args[0] instanceof Request) {
            $request = $args[0];
        }

        if (isset($args[0]) and is_string($args[0])) {
            $params = [];

            if (isset($args[1]) and is_array($args[1])) {
                $params = $args[1];
            }

            $request = new Request($params, [], [], [], [], array_merge($_SERVER, ['REQUEST_URI' => $args[0]]));
        }

        if (!isset($request)) {
            throw new InvalidArgumentException('Not a valid path or Request object.');
        }

        foreach ($defaultManipulations as $key => $value) {
            if (!$request->get($key)) {
                $request->query->set($key, $value);
            }
        }

        return $request;
    }
}
<commit_msg>Improve invalid request exception message.<commit_after><?php

namespace League\Glide\Requests;

use Symfony\Component\HttpFoundation\Request;

class RequestFactory
{
    /**
     * Create a request instance.
     * @param  max     $args                 The request object or path/params combination.
     * @param  array   $defaultManipulations The default image manipulations.
     * @return Request The request object.
     */
    public static function create($args, $defaultManipulations = [])
    {
        if (isset($args[0]) and $args[0] instanceof Request) {
            $request = $args[0];
        }

        if (isset($args[0]) and is_string($args[0])) {
            $params = [];

            if (isset($args[1]) and is_array($args[1])) {
                $params = $args[1];
            }

            $request = new Request($params, [], [], [], [], array_merge($_SERVER, ['REQUEST_URI' => $args[0]]));
        }

        if (!isset($request)) {
            throw new InvalidArgumentException('Not a valid path/params combination or Request object.');
        }

        foreach ($defaultManipulations as $key => $value) {
            if (!$request->get($key)) {
                $request->query->set($key, $value);
            }
        }

        return $request;
    }
}

{'fraction_non_alphanumeric': 0.14263074484944532, 'fraction_numerical': 0.0071315372424722665, 'mean_word_length': 2.056900726392252, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5263427', 'n_tokens_mistral': 698, 'n_tokens_neox': 684, 'n_words': 173}