<commit_before><?php

namespace Embed\ImageInfo;

use GuzzleHttp\Client;
use GuzzleHttp\Pool;
use GuzzleHttp\Exception\RequestException;

/**
 * Class to retrieve the size and mimetype of images using Guzzle5.
 */
class Guzzle5 implements ImageInfoInterface
{
    use UtilsTrait;

    protected static $config = [
        'verify' => false,
        'timeout' => 10,
        'connect_timeout' => 20,
        'headers' => [
            'User-Agent' => 'Embed PHP Library',
        ],
        'allow_redirects' => [
            'max' => 20,
            'referer' => true,
        ],
    ];

    /**
     * {@inheritdoc}
     */
    public static function getImagesInfo(array $urls, array $config = null)
    {
        $client = isset($config['client']) ? $config['client'] : new Client([
            'defaults' => static::$config,
        ]);

        $result = [];

        // Build parallel requests
        $requests = [];
        foreach ($urls as $url) {
            if (strpos($url['value'], 'data:') === 0) {
                if ($info = static::getEmbeddedImageInfo($url['value'])) {
                    $result[] = array_merge($url, $info);
                }
                continue;
            }

            $requests[] = $client->createRequest('GET', $url['value']);
        }

        // Execute in parallel
        $responses = Pool::batch($client, $requests);

        // Build result set
        foreach ($responses as $i => $response) {
            if ($response instanceof RequestException) {
                continue;
            }

            if (($size = getimagesizefromstring($response->getBody())) !== false) {
                $result[] = [
                    'width' => $size[0],
                    'height' => $size[1],
                    'size' => $size[0] * $size[1],
                    'mime' => $size['mime'],
                ] + $urls[$i];
            }
        }

        return $result;
    }
}<commit_msg>apply the same fix to guzzle5<commit_after><?php

namespace Embed\ImageInfo;

use GuzzleHttp\Client;
use GuzzleHttp\Pool;
use GuzzleHttp\Exception\RequestException;

/**
 * Class to retrieve the size and mimetype of images using Guzzle5.
 */
class Guzzle5 implements ImageInfoInterface
{
    use UtilsTrait;

    protected static $config = [
        'verify' => false,
        'timeout' => 10,
        'connect_timeout' => 20,
        'headers' => [
            'User-Agent' => 'Embed PHP Library',
        ],
        'allow_redirects' => [
            'max' => 20,
            'referer' => true,
        ],
    ];

    /**
     * {@inheritdoc}
     */
    public static function getImagesInfo(array $urls, array $config = null)
    {
        $client = isset($config['client']) ? $config['client'] : new Client([
            'defaults' => static::$config,
        ]);

        $result = [];

        // Build parallel requests
        $requests = [];
        foreach ($urls as $k => $url) {
            if (strpos($url['value'], 'data:') === 0) {
                if ($info = static::getEmbeddedImageInfo($url['value'])) {
                    $result[$k] = array_merge($url, $info);
                }
                continue;
            }

            $requests[$k] = $client->createRequest('GET', $url['value']);
        }

        // Execute in parallel
        $responses = Pool::batch($client, $requests);

        // Build result set
        foreach ($responses as $k => $response) {
            if ($response instanceof RequestException) {
                continue;
            }

            if (($size = getimagesizefromstring($response->getBody())) !== false) {
                $result[$k] = [
                    'width' => $size[0],
                    'height' => $size[1],
                    'size' => $size[0] * $size[1],
                    'mime' => $size['mime'],
                ] + $urls[$k];
            }
        }

        ksort($result, SORT_NUMERIC);

        return $result;
    }
}
{'fraction_non_alphanumeric': 0.15515059478613008, 'fraction_numerical': 0.00683371298405467, 'mean_word_length': 1.6189529489728296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, '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': '5799663', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1097, 'n_words': 248}