<commit_before><?php

/*
 * Mendo Framework
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Mendo\Router;

/**
 * @author <NAME> <<EMAIL>>
 */
class RouteData
{
    private $routeName;
    private $params;

    public function __construct($routeName, array $params = [])
    {
        $this->routeName = $routeName;
        $this->params = $params;
    }

    public function getRouteName()
    {
        return $this->routeName;
    }

    public function getParams()
    {
        return $this->params;
    }

    public function getParam(...$args)
    {
        switch (count($args)) {
            default:
                throw new \InvalidArgumentException('getParam() takes one or two arguments');
            case 1:
                if (!$this->hasParam($args[0])) {
                    throw new \InvalidArgumentException('Route param "'.$args[0].'" not found');
                }
                return $this->params[$args[0]];
            case 2:
                if (!$this->hasParam($args[0])) {
                    return $args[1];
                }
                return $this->params[$args[0]];
        }
    }

    public function hasParam($name)
    {
        if ((string) $name === '') {
            throw new \InvalidArgumentException('$name cannot be empty');
        }

        return isset($this->params[$name]);
    }

    public function setParams($params)
    {
        $this->params = $params;
    }

    public function setParam($name, $value)
    {
        if ((string) $name === '') {
            throw new \InvalidArgumentException('$name cannot be empty');
        }

        $this->params[$name] = $value;
    }
}<commit_msg>Make RouteData immutable<commit_after><?php

/*
 * Mendo Framework
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Mendo\Router;

/**
 * @author <NAME> <<EMAIL>>
 */
class RouteData
{
    private $routeName;
    private $params;

    public function __construct($routeName, array $params = [])
    {
        $this->routeName = $routeName;
        $this->params = $params;
    }

    public function getRouteName()
    {
        return $this->routeName;
    }

    public function getParams()
    {
        return $this->params;
    }

    public function getParam(...$args)
    {
        switch (count($args)) {
            default:
                throw new \InvalidArgumentException('getParam() takes one or two arguments');
            case 1:
                if (!$this->hasParam($args[0])) {
                    throw new \InvalidArgumentException('Route param "'.$args[0].'" not found');
                }
                return $this->params[$args[0]];
            case 2:
                if (!$this->hasParam($args[0])) {
                    return $args[1];
                }
                return $this->params[$args[0]];
        }
    }

    public function hasParam($name)
    {
        if ((string) $name === '') {
            throw new \InvalidArgumentException('$name cannot be empty');
        }

        return isset($this->params[$name]);
    }
}
{'fraction_non_alphanumeric': 0.1400611620795107, 'fraction_numerical': 0.004892966360856269, 'mean_word_length': 1.8468233246301131, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, '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': '3663015', 'n_tokens_mistral': 925, 'n_tokens_neox': 883, 'n_words': 233}