<commit_before><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\RoutingBundle\Generator;

use Doctrine\Common\Util\Debug;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use WellCommerce\Bundle\RoutingBundle\Entity\RouteInterface;

/**
 * Class AbstractRouteGenerator
 *
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractRouteGenerator implements RouteGeneratorInterface
{
    /**
     * @var array
     */
    protected $defaults;
    
    /**
     * @var array
     */
    protected $options;
    
    /**
     * @var array
     */
    protected $requirements;
    
    /**
     * @var array
     */
    protected $pattern;
    
    /**
     * AbstractRouteGenerator constructor.
     *
     * @param array  $defaults
     * @param array  $requirements
     * @param string $pattern
     * @param array  $options
     */
    public function __construct(array $defaults = [], array $requirements = [], string $pattern, array $options = [])
    {
        $this->defaults     = $defaults;
        $this->options      = $options;
        $this->requirements = $requirements;
        $this->pattern      = $pattern;
    }
    
    public function generate(RouteInterface $resource) : Route
    {
        $this->defaults['id']      = $resource->getIdentifier()->getId();
        $this->defaults['_locale'] = $resource->getLocale();
        
        return new Route(
            $this->getPath($resource),
            $this->defaults,
            $this->requirements,
            $this->options
        );
    }
    
    private function prepareRouteDefaults(RouteInterface $resource)
    {
        $this->defaults['id']      = $resource->getIdentifier()->getId();
        $this->defaults['_locale'] = $resource->getLocale();
    }

    /**
     * Returns a concatenated path
     *
     * @param RouteInterface $resource
     *
     * @return string
     */
    protected function getPath(RouteInterface $resource) : string
    {
        if (strlen($this->pattern)) {
            return $resource->getPath() . RouteGeneratorInterface::PATH_PARAMS_SEPARATOR . $this->pattern;
        }
        
        return $resource->getPath();
    }
}
<commit_msg>Optimized imports<commit_after><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\RoutingBundle\Generator;

use Symfony\Component\Routing\Route;
use WellCommerce\Bundle\RoutingBundle\Entity\RouteInterface;

/**
 * Class AbstractRouteGenerator
 *
 * @author  <NAME> <<EMAIL>>
 */
abstract class AbstractRouteGenerator implements RouteGeneratorInterface
{
    /**
     * @var array
     */
    protected $defaults;
    
    /**
     * @var array
     */
    protected $options;
    
    /**
     * @var array
     */
    protected $requirements;
    
    /**
     * @var array
     */
    protected $pattern;
    
    /**
     * AbstractRouteGenerator constructor.
     *
     * @param array  $defaults
     * @param array  $requirements
     * @param string $pattern
     * @param array  $options
     */
    public function __construct(array $defaults = [], array $requirements = [], string $pattern, array $options = [])
    {
        $this->defaults     = $defaults;
        $this->options      = $options;
        $this->requirements = $requirements;
        $this->pattern      = $pattern;
    }
    
    public function generate(RouteInterface $resource) : Route
    {
        $this->defaults['id']      = $resource->getIdentifier()->getId();
        $this->defaults['_locale'] = $resource->getLocale();
        
        return new Route(
            $this->getPath($resource),
            $this->defaults,
            $this->requirements,
            $this->options
        );
    }
    
    private function prepareRouteDefaults(RouteInterface $resource)
    {
        $this->defaults['id']      = $resource->getIdentifier()->getId();
        $this->defaults['_locale'] = $resource->getLocale();
    }

    /**
     * Returns a concatenated path
     *
     * @param RouteInterface $resource
     *
     * @return string
     */
    protected function getPath(RouteInterface $resource) : string
    {
        if (strlen($this->pattern)) {
            return $resource->getPath() . RouteGeneratorInterface::PATH_PARAMS_SEPARATOR . $this->pattern;
        }
        
        return $resource->getPath();
    }
}

{'fraction_non_alphanumeric': 0.12762419455414675, 'fraction_numerical': 0.0, 'mean_word_length': 2.3004115226337447, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 59, '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': '3501192', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1323, 'n_words': 295}