<commit_before><?php
namespace luya\helpers;

use \yii;

class Url
{
    /**
     * get an array from the route which returns the module controller and action
     *
     * @param string $route
     */
    public static function fromRoute($route, $returnPart = false)
    {
        $parts = explode("/", $route);
        
        if (count($parts) == 3) {
            list($module, $controller, $action) = $parts;
        }
        
        if (count($parts) !== 3) {
            return false;
        }
        
        $parts = [
            "module" => $module,
            "controller" => $controller,
            "action" => $action
        ];
        
        if ($returnPart !== false) {
            return $parts[$returnPart];
        }
        
        return $parts;
    }
    
    public static function to($route, array $params = [])
    {
        $routeParams = [$route];
        foreach ($params as $key => $value) {
            $routeParams[$key] = $value;
        }
        
        return yii::$app->urlManager->createUrl($routeParams);
    }
}<commit_msg>[+] added trailing<commit_after><?php
namespace luya\helpers;

use \yii;

class Url
{
    /**
     * get an array from the route which returns the module controller and action
     *
     * @param string $route
     */
    public static function fromRoute($route, $returnPart = false)
    {
        $parts = explode("/", $route);
        
        if (count($parts) == 3) {
            list($module, $controller, $action) = $parts;
        }
        
        if (count($parts) !== 3) {
            return false;
        }
        
        $parts = [
            "module" => $module,
            "controller" => $controller,
            "action" => $action
        ];
        
        if ($returnPart !== false) {
            return $parts[$returnPart];
        }
        
        return $parts;
    }
    
    /**
     * add a trailing slash to an url if there is no trailing slash at the end of the url
     * 
     * @param string $url The url which a trailing slash should be appended
     */
    public static function trailing($url)
    {
        return $url .  (substr($url, -1) == '/' ? '' : '/');
    }
    
    /**
     * Wrapper functions for the createUrl function of the url manager.
     * 
     * @param string $route
     * @param array $params
     */
    public static function to($route, array $params = [])
    {
        $routeParams = [$route];
        foreach ($params as $key => $value) {
            $routeParams[$key] = $value;
        }
        
        return yii::$app->urlManager->createUrl($routeParams);
    }
}
{'fraction_non_alphanumeric': 0.13471106008419442, 'fraction_numerical': 0.0019135093761959434, 'mean_word_length': 1.58300395256917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6917624', 'n_tokens_mistral': 750, 'n_tokens_neox': 739, 'n_words': 207}