<commit_before><?php declare(strict_types=1);

namespace Novuso\Common\Adapter\Routing;

use Aura\Router\Generator;
use Novuso\Common\Application\Routing\Exception\UrlGenerationException;
use Novuso\Common\Application\Routing\UrlGeneratorInterface;
use Throwable;

/**
 * AuraUrlGenerator is an adapter for an Aura URL generator
 *
 * @copyright Copyright (c) 2017, Novuso. <http://novuso.com>
 * @license   http://opensource.org/licenses/MIT The MIT License
 * @author    <NAME> <<EMAIL>>
 */
class AuraUrlGenerator implements UrlGeneratorInterface
{
    /**
     * Aura URL generator
     *
     * @var Generator
     */
    protected $urlGenerator;

    /**
     * Base URL path
     *
     * @var string
     */
    protected $basePath;

    /**
     * Constructs AuraUrlGenerator
     *
     * @param Generator $urlGenerator The Aura URL generator
     * @param string    $basePath     The base path for absolute paths
     */
    public function __construct(Generator $urlGenerator, string $basePath)
    {
        $this->urlGenerator = $urlGenerator;
        $this->basePath = $basePath;
    }

    /**
     * {@inheritdoc}
     */
    public function generate(string $name, array $parameters = [], array $query = [], bool $absolute = false): string
    {
        try {
            $url = $this->urlGenerator->generateRaw($name, $parameters);

            if (!empty($query)) {
                $url .= '?'.http_build_query($query);
            }

            if ($absolute) {
                $url = $this->basePath.$url;
            }

            return $url;
        } catch (Throwable $e) {
            throw new UrlGenerationException($e->getMessage(), $e->getCode(), $e);
        }
    }
}
<commit_msg>url encoding<commit_after><?php declare(strict_types=1);

namespace Novuso\Common\Adapter\Routing;

use Aura\Router\Generator;
use Novuso\Common\Application\Routing\Exception\UrlGenerationException;
use Novuso\Common\Application\Routing\UrlGeneratorInterface;
use Throwable;

/**
 * AuraUrlGenerator is an adapter for an Aura URL generator
 *
 * @copyright Copyright (c) 2017, Novuso. <http://novuso.com>
 * @license   http://opensource.org/licenses/MIT The MIT License
 * @author    <NAME> <<EMAIL>>
 */
class AuraUrlGenerator implements UrlGeneratorInterface
{
    /**
     * Aura URL generator
     *
     * @var Generator
     */
    protected $urlGenerator;

    /**
     * Base URL path
     *
     * @var string
     */
    protected $basePath;

    /**
     * Constructs AuraUrlGenerator
     *
     * @param Generator $urlGenerator The Aura URL generator
     * @param string    $basePath     The base path for absolute paths
     */
    public function __construct(Generator $urlGenerator, string $basePath)
    {
        $this->urlGenerator = $urlGenerator;
        $this->basePath = $basePath;
    }

    /**
     * {@inheritdoc}
     */
    public function generate(string $name, array $parameters = [], array $query = [], bool $absolute = false): string
    {
        try {
            $url = $this->urlGenerator->generate($name, $parameters);

            if (!empty($query)) {
                $url .= '?'.http_build_query($query);
            }

            if ($absolute) {
                $url = $this->basePath.$url;
            }

            return $url;
        } catch (Throwable $e) {
            throw new UrlGenerationException($e->getMessage(), $e->getCode(), $e);
        }
    }
}

{'fraction_non_alphanumeric': 0.12675233644859812, 'fraction_numerical': 0.0029205607476635513, 'mean_word_length': 2.318798449612403, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, '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': '3930369', 'n_tokens_mistral': 989, 'n_tokens_neox': 974, 'n_words': 233}