<commit_before><?php

namespace LastCall\Crawler\Uri;

use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;

/**
 * Normalize URLs to a consistent state.
 *
 * @see https://tools.ietf.org/html/rfc3986
 */
class Normalizer
{
    private $handlers = [];

    public function __construct(array $handlers = [], $traceable = false)
    {
        $this->handlers = $handlers;
        $this->traceable = $traceable;
    }

    public function __invoke(UriInterface $uri)
    {
        if ($this->traceable && !$uri instanceof TraceableUri) {
            $uri = new TraceableUri($uri);
        }

        do {
            $str = (string) $uri;
            foreach ($this->handlers as $handler) {
                $uri = $handler($uri);
            }
            $newStr = (string) $uri;
        }
        // Normalization is achieved once running normalizers causes no changes.
        while ($str !== $newStr);

        return $uri;
    }

    protected function createUri($uri)
    {
        if (!$uri instanceof UriInterface) {
            $uri = new Uri($uri);
        }
        if (!$uri instanceof TraceableUri) {
            $uri = new TraceableUri($uri);
        }

        return $uri;
    }
}<commit_msg>Remove unused method on Normalizer<commit_after><?php

namespace LastCall\Crawler\Uri;

use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;

/**
 * Normalize URLs to a consistent state.
 *
 * @see https://tools.ietf.org/html/rfc3986
 */
class Normalizer
{
    private $handlers = [];

    public function __construct(array $handlers = [], $traceable = false)
    {
        $this->handlers = $handlers;
        $this->traceable = $traceable;
    }

    public function __invoke(UriInterface $uri)
    {
        if ($this->traceable && !$uri instanceof TraceableUri) {
            $uri = new TraceableUri($uri);
        }

        do {
            $str = (string) $uri;
            foreach ($this->handlers as $handler) {
                $uri = $handler($uri);
            }
            $newStr = (string) $uri;
        }
        // Normalization is achieved once running normalizers causes no changes.
        while ($str !== $newStr);

        return $uri;
    }
}
{'fraction_non_alphanumeric': 0.1295787545787546, 'fraction_numerical': 0.004578754578754579, 'mean_word_length': 2.009641873278237, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '884193', 'n_tokens_mistral': 668, 'n_tokens_neox': 648, 'n_words': 159}