Habari\URL::parse PHP Метод

parse() публичный статический Метод

This method is used by the Controller class for parsing requests, and by other classes, such as Pingback, which uses it to determine the post slug for a given URL. Returns the matched RewriteRule object, or false.
public static parse ( string $from_url ) : RewriteRule
$from_url string URL string to parse
Результат RewriteRule matched rule, or false
    public static function parse($from_url)
    {
        $base_url = Site::get_path('base', true);
        /*
         * Strip out the base URL from the requested URL
         * but only if the base URL isn't /
         */
        if (strpos($from_url, $base_url) === 0) {
            $from_url = MultiByte::substr($from_url, MultiByte::strlen($base_url));
        }
        /* Trim off any leading or trailing slashes */
        $from_url = trim($from_url, '/');
        /* Remove the querystring from the URL */
        if (MultiByte::strpos($from_url, '?') !== false) {
            list($from_url, ) = explode('?', $from_url);
        }
        $url = URL::instance();
        $url->load_rules();
        // Cached in singleton
        /*
         * Run the stub through the regex matcher
         */
        self::$stub = $from_url;
        /** @var RewriteRule $rule */
        foreach ($url->rules as $rule) {
            if ($rule->match($from_url)) {
                $url->matched_rule = $rule;
                /* Stop processing at first matched rule... */
                return $rule;
            }
        }
        return false;
    }