<commit_before><?php
/**
 * This is a part of Maketok Site. Licensed under GPL 3.0
 * @project site
 * @developer <NAME> <EMAIL> <EMAIL>
 */

namespace Maketok\Mvc\Router\Route\Http;


use Maketok\Mvc\Router\Route\RouteInterface;
use Maketok\Mvc\Router\Route\Success;
use Maketok\Util\RequestInterface;
use Maketok\Util\ExpressionParser;
use Maketok\Util\ExpressionParserInterface;
use Maketok\Util\Tokenizer;
use Symfony\Component\HttpFoundation\ParameterBag;

class Parameterized extends AbstractRoute implements RouteInterface
{

    /** @var  ExpressionParserInterface */
    protected $expressionParser;

    /** @var  array */
    protected $variables;

    /** @var  array */
    protected $defaults;

    /** @var  array */
    protected $restrictions;

    /**
     * @param string $path
     * @param array $resolver
     * @param array $defaults
     * @param array $restrictions
     * @param \Maketok\Util\ExpressionParserInterface $parser
     */
    public function __construct($path, $resolver, array $defaults, array $restrictions, ExpressionParserInterface $parser = null)
    {
        $this->setPath($path);
        $this->resolver = $resolver;
        $this->defaults = $defaults;
        $this->restrictions = $restrictions;
        if (is_null($parser)) {
            $this->expressionParser = new ExpressionParser($this->matchPath, new Tokenizer($this->matchPath));
        } else {
            $this->expressionParser = $parser;
        }
    }

    /**
     * @param RequestInterface $request
     * @return bool|Success
     */
    public function match(RequestInterface $request)
    {
        $this->request = $request;
        $this->variables = $this->expressionParser->parse(
            $this->stripTrailingSlash($request->getPathInfo()),
            $this->restrictions
        );
        if ($this->variables !== FALSE) {
            $attributes = $request->getAttributes();
            if (is_object($attributes) && ($attributes instanceof ParameterBag)) {
                $attributes->add(array(
                    '_route' => $this,
                ));
                // set defaults
                if (!empty($this->defaults)) {
                    $attributes->add($this->defaults);
                }
                // set variables
                if (!empty($this->variables)) {
                    $attributes->add($this->variables);
                }
            }
            return new Success($this);
        }
        return false;
    }

    /**
     * @param array $params
     * @return string
     */
    public function assemble(array $params = array())<commit_msg>remove trailing comma<commit_after><?php
/**
 * This is a part of Maketok Site. Licensed under GPL 3.0
 * @project site
 * @developer <NAME> <EMAIL> maketok.com
 */

namespace Maketok\Mvc\Router\Route\Http;


use Maketok\Mvc\Router\Route\RouteInterface;
use Maketok\Mvc\Router\Route\Success;
use Maketok\Util\RequestInterface;
use Maketok\Util\ExpressionParser;
use Maketok\Util\ExpressionParserInterface;
use Maketok\Util\Tokenizer;
use Symfony\Component\HttpFoundation\ParameterBag;

class Parameterized extends AbstractRoute implements RouteInterface
{

    /** @var  ExpressionParserInterface */
    protected $expressionParser;

    /** @var  array */
    protected $variables;

    /** @var  array */
    protected $defaults;

    /** @var  array */
    protected $restrictions;

    /**
     * @param string $path
     * @param array $resolver
     * @param array $defaults
     * @param array $restrictions
     * @param \Maketok\Util\ExpressionParserInterface $parser
     */
    public function __construct($path, $resolver, array $defaults, array $restrictions, ExpressionParserInterface $parser = null)
    {
        $this->setPath($path);
        $this->resolver = $resolver;
        $this->defaults = $defaults;
        $this->restrictions = $restrictions;
        if (is_null($parser)) {
            $this->expressionParser = new ExpressionParser($this->matchPath, new Tokenizer($this->matchPath));
        } else {
            $this->expressionParser = $parser;
        }
    }

    /**
     * @param RequestInterface $request
     * @return bool|Success
     */
    public function match(RequestInterface $request)
    {
        $this->request = $request;
        $this->variables = $this->expressionParser->parse(
            $this->stripTrailingSlash($request->getPathInfo()),
            $this->restrictions
        );
        if ($this->variables !== FALSE) {
            $attributes = $request->getAttributes();
            if (is_object($attributes) && ($attributes instanceof ParameterBag)) {
                $attributes->add(array(
                    '_route' => $this
                ));
                // set defaults
                if (!empty($this->defaults)) {
                    $attributes->add($this->defaults);
                }
                // set variables
                if (!empty($this->variables)) {
                    $attributes->add($this->variables);
                }
            }
            return new Success($this);
        }
        return false;
    }

    /**
     * @param array $params
     * @return string
     */
    public function assemble(array $params = array())
{'fraction_non_alphanumeric': 0.12711703139866792, 'fraction_numerical': 0.0007611798287345385, 'mean_word_length': 2.181598062953995, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 58, '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': '6032119', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1392, 'n_words': 305}