<commit_before><?php
/**
 * This file is part of the PPI Framework.
 *
 * @copyright  Copyright (c) 2012 <NAME> <<EMAIL>>
 * @license    http://opensource.org/licenses/mit-license.php MIT
 * @link       http://www.ppi.io
 */
namespace PPI\Module\Routing;

/**
 * The routing helper for the controller.
 *
 * @package    PPI
 * @subpackage Module
 */
class RoutingHelper
{
    /**
     * The routing params
     *
     * @var array
     */
    protected $params = array();

    protected $activeRouteName;

    /**
     * Constructor.
     *
     * @param array $params
     *
     * @return void
     */
    public function __construct(array $params = array())
    {
        if (!empty($params)) {
            $this->setParams($params);
        }
    }

    /**
     * Obtain a param's value
     *
     * @param string $param The param name
     *
     * @return type
     *
     * @throws \InvalidArgumentException When the param does not exist
     */
    public function getParam($param)
    {
        if (!isset($this->params[$param])) {
            throw new \InvalidArgumentException('Unable to find routing param: ' . $param);
        }

        return $this->params[$param];
    }

    /**
     * Set a routing param's value
     *
     * @param string $param
     * @param string $value
     *
     * @return void
     */
    public function setParam($param, $value)
    {
        $this->params[$param] = $value;
    }

    /**<commit_msg>[Routing] Adding in a hasParam() method to the routing helper.<commit_after><?php
/**
 * This file is part of the PPI Framework.
 *
 * @copyright  Copyright (c) 2012 <NAME> <<EMAIL>>
 * @license    http://opensource.org/licenses/mit-license.php MIT
 * @link       http://www.ppi.io
 */
namespace PPI\Module\Routing;

/**
 * The routing helper for the controller.
 *
 * @package    PPI
 * @subpackage Module
 */
class RoutingHelper
{
    /**
     * The routing params
     *
     * @var array
     */
    protected $params = array();

    protected $activeRouteName;

    /**
     * Constructor.
     *
     * @param array $params
     *
     * @return void
     */
    public function __construct(array $params = array())
    {
        if (!empty($params)) {
            $this->setParams($params);
        }
    }

    /**
     * Obtain a param's value
     *
     * @param string $param The param name
     *
     * @return type
     *
     * @throws \InvalidArgumentException When the param does not exist
     */
    public function getParam($param)
    {
        if (!isset($this->params[$param])) {
            throw new \InvalidArgumentException('Unable to find routing param: ' . $param);
        }

        return $this->params[$param];
    }

    /**
     * Set a routing param's value
     *
     * @param string $param
     * @param string $value
     *
     * @return void
     */
    public function setParam($param, $value)
    {
        $this->params[$param] = $value;
    }

    /**
     * Check if a routing param exists
     * 
     * @param string $param
     * @return bool
     */
    public function hasParam($param)
    {
        return array_key_exists($param, $this->params);
    }

    /**
{'fraction_non_alphanumeric': 0.13400758533501897, 'fraction_numerical': 0.0025284450063211127, 'mean_word_length': 1.9143646408839778, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4638448', 'n_tokens_mistral': 968, 'n_tokens_neox': 926, 'n_words': 250}