<commit_before><?php

namespace Moccalotto\SshPortal;

use RuntimeException;

class Http extends Singletonian
{
    /**
     * @var array
     */
    protected $defaultContextOptions;

    /**
     * Constructor.
     */
    protected function __construct()
    {
        $this->defaultContextOptions = [
            'http' => Config::get('http'),
            'ssl' => Config::get('https'),
        ];
    }

    /**
     * Make an HTTP request.
     *
     * @param string       $url
     * @param string|array $content
     * @param array        $headers
     * @param string       $method
     *
     * @return string
     */
    public function doRequest(string $url, $content = null, array $headers = [], string $method = 'GET')
    {
        $context_options = array_replace_recursive($this->defaultContextOptions, [
            'http' => [
                'method' => $method,
                'header' => $headers,
                'content' => $content,
            ],
        ]);

        $response = file_get_contents($url, false, stream_context_create($context_options));

        $http_header = $http_response_header[0];

        // We must have a 2xx header.
        if (!preg_match('#HTTP/\\d+\\.\\d+\\s+2\\d{2}#Ai', $http_header)) {
            throw new RuntimeException(sprintf(
                'Bad response from server: "%s"',
                $http_header
            ));
        }

        return $response;
    }
}<commit_msg>Remove unnecessary code.<commit_after><?php

namespace Moccalotto\SshPortal;

use RuntimeException;

class Http extends Singletonian
{
    /**
     * @var array
     */
    protected $defaultContextOptions;

    /**
     * Constructor.
     */
    protected function __construct()
    {
        $this->defaultContextOptions = [
            'http' => Config::get('http'),
            'ssl' => Config::get('https'),
        ];
    }

    /**
     * Make an HTTP request.
     *
     * @param string       $url
     * @param string|array $content
     * @param array        $headers
     * @param string       $method
     *
     * @return string
     */
    public function doRequest(string $url, $content = null, array $headers = [], string $method = 'GET')
    {
        $context_options = array_replace_recursive($this->defaultContextOptions, [
            'http' => [
                'method' => $method,
                'header' => $headers,
                'content' => $content,
            ],
        ]);

        $response = file_get_contents($url, false, stream_context_create($context_options));

        return $response;
    }
}
{'fraction_non_alphanumeric': 0.13655705996131529, 'fraction_numerical': 0.0015473887814313346, 'mean_word_length': 1.8169934640522876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1297536', 'n_tokens_mistral': 744, 'n_tokens_neox': 723, 'n_words': 154}