<commit_before><?php
namespace Simox;

class Url extends SimoxServiceBase
{
    private $_root_path;
    
    /**
     * Base uri is prepended to all resources (css, images, links..)
     */
	private $_uri_prefix;
	
	public function __construct()
    {
        $this->_uri_prefix = "/";
        
        $this->_root_path = realpath(__DIR__ . "/../../../../");
    }
    
    public function getRootPath()
    {
        return $this->_root_path;
    }
	
    /**
     * Sets the uri prefix
     * 
     * @param string $uri_prefix
     */
	public function setUriPrefix( $uri_prefix )
	{
        $uri_prefix = preg_replace( "#/+#", "/", "/" . $uri_prefix . "/" );
        
		$this->_uri_prefix = $uri_prefix;
	}
	
    /**
     * Returns the base uri
     * 
     * @return string
     */
	public function getUriPrefix()
	{
		return $this->_uri_prefix;
	}
    
    /**
     * Appends a given path to the base uri
     * 
     * @param string $path
     * @return string
     */
    public function get( $path )
    {
        return preg_replace( "#/+#", "/", $this->getUriPrefix() . $path );
    }
}<commit_msg>add format function to make code more dry<commit_after><?php
namespace Simox;

class Url extends SimoxServiceBase
{
    private $_root_path;
    
    /**
     * Uri prefix is prepended to all resources (css, images, links..)
     */
	private $_uri_prefix;
	
	public function __construct()
    {
        $this->_uri_prefix = null;
        
        $this->_root_path = realpath( __DIR__ . "/../../../../" );
    }

    /**
     * Returns a formatted uri.
     * Gives all uri:s a consistent format.
     */
    public function _format( $uri )
    {
        return preg_replace( "#/+#", "/", "/" . $uri );
    }
    
    public function getRootPath()
    {
        return $this->_root_path;
    }
	
    /**
     * Sets the uri prefix
     * 
     * @param string $uri_prefix
     */
	public function setUriPrefix( $uri_prefix )
	{
		$this->_uri_prefix = $this->_format( $uri_prefix . "/" );
	}
	
    /**
     * Returns the uri prefix
     * 
     * @return string
     */
	public function getUriPrefix()
	{
		return $this->_uri_prefix;
	}
    
    /**
     * Returns a given path appended to the uri prefix
     * 
     * @param string $path
     * @return string
     */
    public function get( $path )
    {
        return $this->_format( $this->getUriPrefix() . $path );
    }
}
{'fraction_non_alphanumeric': 0.1436950146627566, 'fraction_numerical': 0.0, 'mean_word_length': 1.8394768133174793, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '703892', 'n_tokens_mistral': 782, 'n_tokens_neox': 751, 'n_words': 185}