<commit_before><?php

namespace GenderApi\Client\Downloader;

use GenderApi\Client\InvalidParameterException;

/**
 * Class AbstractDownloader
 * @package GenderApi\Client\Downloader
 *
 */
abstract class AbstractDownloader
{
    /**
     * @var bool
     */
    protected $useProxy = false;

    /**
     * @var string
     */
    protected $proxyHost = '';

    /**
     * @var int
     */
    protected $proxyPort = 3128;

    /**
     * @param string $url
     * @return string
     */
    abstract public function download($url);

    /**
     * Set a proxy server for every request.
     *
     * @param string|null $host
     * @param int|null $port
     * @throws InvalidParameterException
     */
    public function setProxy($host = null, $port = null)
    {
        if (!$host) {
            $this->proxyHost = null;
            $this->proxyPort = null;
            return;
        }

        if (!is_string($host)) {
            throw new InvalidParameterException('Invalid Parameter for $host. String expected, ' . gettype($host) . ' given.');
        }

        if (!is_int($port)) {
            throw new InvalidParameterException('Invalid Parameter for $port. Int expected, ' . gettype($port) . ' given.');
        }

        $this->proxyHost = $host;
        $this->proxyPort = $port;
    }

    /**
     * @return string|null
     */
    public function getProxy()
    {
        if ($this->proxyHost) {
            return $this->proxyHost . ':' . $this->proxyPort;
        }

        return null;
    }
}<commit_msg>Proxy Server Support<commit_after><?php

namespace GenderApi\Client\Downloader;

use GenderApi\Client\InvalidParameterException;

/**
 * Class AbstractDownloader
 * @package GenderApi\Client\Downloader
 *
 */
abstract class AbstractDownloader
{

    /**
     * @var string
     */
    protected $proxyHost = '';

    /**
     * @var int
     */
    protected $proxyPort = 3128;

    /**
     * @param string $url
     * @return string
     */
    abstract public function download($url);

    /**
     * Set a proxy server for every request.
     *
     * @param string|null $host
     * @param int|null $port
     * @throws InvalidParameterException
     */
    public function setProxy($host = null, $port = null)
    {
        if (!$host) {
            $this->proxyHost = null;
            $this->proxyPort = null;
            return;
        }

        if (!is_string($host)) {
            throw new InvalidParameterException('Invalid Parameter for $host. String expected, ' . gettype($host) . ' given.');
        }

        if (!is_int($port)) {
            throw new InvalidParameterException('Invalid Parameter for $port. Int expected, ' . gettype($port) . ' given.');
        }

        $this->proxyHost = $host;
        $this->proxyPort = $port;
    }

    /**
     * @return string|null
     */
    public function getProxy()
    {
        if ($this->proxyHost) {
            return $this->proxyHost . ':' . $this->proxyPort;
        }

        return null;
    }
}
{'fraction_non_alphanumeric': 0.13359920239282153, 'fraction_numerical': 0.0026586905948820204, 'mean_word_length': 1.9223300970873787, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7245490', 'n_tokens_mistral': 874, 'n_tokens_neox': 850, 'n_words': 203}