<commit_before><?php

/**
 * View_Helper_Value_Url
 *
 * @category PHP
 * @package Mol_View
 * @author <NAME> <<EMAIL>>
 * @copyright 2010-2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 17.10.2010
 */

/**
 * Contains url data and generates the url if it is casted to a string.
 *
 * @category PHP
 * @package Mol_View
 * @author <NAME> <<EMAIL>>
 * @copyright 2010-2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 17.10.2010
 */
class Mol_View_Helper_Value_Url
{
    /**
     * The view object that is used to access other url helpers.
     *
     * @var Zend_View_Interface
     */
    protected $view = null;

    /**
     * The url parameters.
     *
     * The name is used as key, the value contains the parameter.
     *
     * @var array(string=>string)
     */
    protected $params = array();

    /**
     * The name of the route that is used.
     *
     * If $route is null then the current route is used.
     *
     * @var string|null
     */
    protected $route = null;

    /**
     * Flag that indicates if the current request params will be resetted.
     *
     * @var boolean
     */
    protected $resetParams = true;

    /**
     * The used anchor.
     *
     * Is null if no anchor is used.
     *
     * @var string|null
     */
    protected $anchor = null;

    /**
     * Creates a object that represents a url.
     *
     * @param Zend_View_Interface $view
     */
    public function __construct(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    /**
     * Adds the parameter $name with the value $value to this url.
     *
     * @param string $name
     * @param string $value
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withParam($name, $value)
    {
        $this->params[$name] = (string)$value;
        return $this;
    }

    /**
     * Ensures that the route $name is used.
     *
     * If null is provided, then the current route will be used.
     *
     * @param string|null $name
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withRoute($name)
    {
        $this->route = $name;
        return $this;
    }

    /**
     * Add the anchor $name to this url.
     *
     * @param string $name
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withAnchor($name)
    {
        $this->anchor = $name;
        return $this;
    }

    /**
     * Ensures that all parameters that where present when the page was
     * requested are added to the url.
     *
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function keepParams()
    {
        $this->resetParams = false;
        return $this;
    }

    /**
     * Returns the url as string.
     *
     * @return string
     */
    public function __toString()
    {
        $anchor = ($this->anchor === null) ? '' : '#' . $this->anchor;
        return $this->view->url($this->params, $this->route, $this->resetParams) . $anchor;
    }

}

<commit_msg>added withQuery() method stub that is used to add a query parameter (#59)<commit_after><?php

/**
 * View_Helper_Value_Url
 *
 * @category PHP
 * @package Mol_View
 * @author <NAME> <<EMAIL>>
 * @copyright 2010-2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 17.10.2010
 */

/**
 * Contains url data and generates the url if it is casted to a string.
 *
 * @category PHP
 * @package Mol_View
 * @author <NAME> <<EMAIL>>
 * @copyright 2010-2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 17.10.2010
 */
class Mol_View_Helper_Value_Url
{
    /**
     * The view object that is used to access other url helpers.
     *
     * @var Zend_View_Interface
     */
    protected $view = null;

    /**
     * The url parameters.
     *
     * The name is used as key, the value contains the parameter.
     *
     * @var array(string=>string)
     */
    protected $params = array();

    /**
     * The name of the route that is used.
     *
     * If $route is null then the current route is used.
     *
     * @var string|null
     */
    protected $route = null;

    /**
     * Flag that indicates if the current request params will be resetted.
     *
     * @var boolean
     */
    protected $resetParams = true;

    /**
     * The used anchor.
     *
     * Is null if no anchor is used.
     *
     * @var string|null
     */
    protected $anchor = null;

    /**
     * Creates a object that represents a url.
     *
     * @param Zend_View_Interface $view
     */
    public function __construct(Zend_View_Interface $view)
    {
        $this->view = $view;
    }

    /**
     * Adds the parameter $name with the value $value to this url.
     *
     * @param string $name
     * @param string $value
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withParam($name, $value)
    {
        $this->params[$name] = (string)$value;
        return $this;
    }
    
    /**
     * Adds a query parameter to this url.
     *
     * Query parameters are not encoded in the url path, instead
     * these parameters are appended via "?" and "&":
     *
     *     /url/path?first=query-param&second=query-param
     *
     * @param string $name
     * @param string $value
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withQuery($name, $value)
    {
        
    }

    /**
     * Ensures that the route $name is used.
     *
     * If null is provided, then the current route will be used.
     *
     * @param string|null $name
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withRoute($name)
    {
        $this->route = $name;
        return $this;
    }

    /**
     * Add the anchor $name to this url.
     *
     * @param string $name
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function withAnchor($name)
    {
        $this->anchor = $name;
        return $this;
    }

    /**
     * Ensures that all parameters that where present when the page was
     * requested are added to the url.
     *
     * @return Mol_View_Helper_Value_Url Provides a fluent interface.
     */
    public function keepParams()
    {
        $this->resetParams = false;
        return $this;
    }

    /**
     * Returns the url as string.
     *
     * @return string
     */
    public function __toString()
    {
        $anchor = ($this->anchor === null) ? '' : '#' . $this->anchor;
        return $this->view->url($this->params, $this->route, $this->resetParams) . $anchor;
    }

}


{'fraction_non_alphanumeric': 0.11727956836575323, 'fraction_numerical': 0.009938946471674003, 'mean_word_length': 2.1003521126760565, 'pattern_counts': {'":': 1, '<': 21, '<?xml version=': 0, '>': 45, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '7370822', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2148, 'n_words': 644}