<commit_before><?php

/**
 * Mol_Validate_Url
 *
 * @category PHP
 * @package Mol_Validate
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 11.03.2013
 */

/**
 * Validator that checks URLs.
 *
 * @category PHP
 * @package Mol_Validate
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 11.03.2013
 */
class Mol_Validate_Url extends Zend_Validate_Abstract
{
    
    /**
     * Key for failure message which indicates that a non-string
     * value was provided.
     *
     * @var string
     */
    const FAILURE_INVALID = 'urlInvalid';
    
    /**
     * Key for failure message which indicates that the validated
     * value is no absolute url.
     *
     * @var string
     */
    const FAILURE_NO_URL = 'urlNoUrl';
    
    /**
     * Default failure messages.
     *
     * @var array(string)
     */
    protected $_messageTemplates = array(
        self::FAILURE_INVALID => "Invalid type given. String expected, but received %value%",
        self::FAILURE_NO_URL  => "'%value%' is no absolute URL"
    );
    
    /**
     * Checks if $value is an absolute URL.
     *
     * @param mixed $value
     * @return boolean
     */
    public function isValid($value)
    {
        $this->_setValue($value);
        if (!is_string($value)) {
            $this->_error(self::FAILURE_INVALID, Mol_Util_Stringifier::stringify($value));
            return false;
        }
        if (!Zend_Uri_Http::check($value)) {
            $this->_error(self::FAILURE_NO_URL);
            return false;
        }
        return true;
    }
    
    /**
     * Sets a list of accepted hostnames.
     *
     * The url is only valid if its hostname is listed in this whitelist.
     * The "*" character can be used as wildcard:
     *
     *     $validHostnames = array(
     *         'github.com',
     *         'gist.github.com',
     *         '*.matthimatiker.de'
     *     );
     *     $validator->setAcceptedHostnames($validHostnames).
     *
     * Per default every hostnam is accepted.
     *
     * @param array(string) $hostnames
     * @return Mol_Validate_Url Provides a fluent interface.
     */
    public function setAcceptedHostnames(array $hostnames)
    {
        
    }
    
    /**
     * Returns a list of accepted hostnames.
     *
     * Hostnames may contain wildcards ("*").
     *
     * @return array(string)
     */
    public function getAcceptedHostnames()
    {
        
    }
    <commit_msg>introduced new failure message type, added method stub<commit_after><?php

/**
 * Mol_Validate_Url
 *
 * @category PHP
 * @package Mol_Validate
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 11.03.2013
 */

/**
 * Validator that checks URLs.
 *
 * @category PHP
 * @package Mol_Validate
 * @author <NAME> <<EMAIL>>
 * @copyright 2013 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 11.03.2013
 */
class Mol_Validate_Url extends Zend_Validate_Abstract
{
    
    /**
     * Key for failure message which indicates that a non-string
     * value was provided.
     *
     * @var string
     */
    const FAILURE_INVALID = 'urlInvalid';
    
    /**
     * Key for failure message which indicates that the validated
     * value is no absolute URL.
     *
     * @var string
     */
    const FAILURE_NO_URL = 'urlNoUrl';
    
    /**
     * Key for failure message which indicates that the hostname
     * of the validated URL was not accepted.
     *
     * @var string
     */
    const FAILURE_HOSTNAME_NOT_ACCEPTED = 'urlHostnameNotAccepted';
    
    /**
     * A list of expected hostnames.
     *
     * The listed hostnams may contain wildcards ("*").
     *
     * @var array(string)
     */
    protected $acceptedHostnames = array();
    
    /**
     * Default failure messages.
     *
     * @var array(string)
     */
    protected $_messageTemplates = array(
        self::FAILURE_INVALID               => "Invalid type given. String expected, but received %value%",
        self::FAILURE_NO_URL                => "'%value%' is no absolute URL",
        self::FAILURE_HOSTNAME_NOT_ACCEPTED => "'%value%' must use an accepted hostname: %acceptedHostnames%"
    );
    
    /**
     * Checks if $value is an absolute URL.
     *
     * @param mixed $value
     * @return boolean
     */
    public function isValid($value)
    {
        $this->_setValue($value);
        if (!is_string($value)) {
            $this->_error(self::FAILURE_INVALID, Mol_Util_Stringifier::stringify($value));
            return false;
        }
        if (!Zend_Uri_Http::check($value)) {
            $this->_error(self::FAILURE_NO_URL);
            return false;
        }
        return true;
    }
    
    /**
     * Sets a list of accepted hostnames.
     *
     * The url is only valid if its hostname is listed in this whitelist.
     * The "*" character can be used as wildcard:
     *
     *     $validHostnames = array(
     *         'github.com',
     *         'gist.github.com',
     *         '*.matthimatiker.de'
     *     );
     *     $validator->setAcceptedHostnames($validHostnames).
     *
     * Per default every hostnam is accepted.
     *
     * @param array(string) $hostnames
     * @return Mol_Validate_Url Provides a fluent interface.
     */
    public function setAcceptedHostnames(array $hostnames)
    {
        
    }
    
    /**
     * Returns a list of accepted hostnames.
     *
     * Hostnames may contain wildcards ("*").
     *
     * @return array(string)
     */
    public function getAcceptedHostnames()
    {
        
    }
    
    /**
     * Checks if hostname restrictions are active.
     *
     * @return boolean True if there are restrictions, false otherwise.
     */
    public function hasHostnameRestrictions()
    {
        
    }
    
{'fraction_non_alphanumeric': 0.11601412066752247, 'fraction_numerical': 0.00834403080872914, 'mean_word_length': 2.099453008453506, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 32, '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': '1274853', 'n_tokens_mistral': 1901, 'n_tokens_neox': 1876, 'n_words': 470}