From 2f999397e3355e33337dd8dec5a3c170c42a0e65 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 7 Jul 2011 07:21:15 -0700 Subject: [PATCH] Trim comment bloat from URL class. --- system/url.php | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/system/url.php b/system/url.php index dfcd8208..a9f23f57 100644 --- a/system/url.php +++ b/system/url.php @@ -12,9 +12,6 @@ class URL { */ public static function to($url = '', $https = false, $asset = false) { - // ---------------------------------------------------- - // Return the URL unchanged if it is already formed. - // ---------------------------------------------------- if (strpos($url, '://') !== false) { return $url; @@ -22,19 +19,13 @@ public static function to($url = '', $https = false, $asset = false) $base = Config::get('application.url'); - // ---------------------------------------------------- - // Assets live in the public directory, so we don't - // want to append the index file to the URL if the - // URL is to an asset. - // ---------------------------------------------------- + // Assets live in the public directory, so we only want to append + // the index file if the URL is to an asset. if ( ! $asset) { $base .= '/'.Config::get('application.index'); } - // ---------------------------------------------------- - // Does the URL need an HTTPS protocol? - // ---------------------------------------------------- if (strpos($base, 'http://') === 0 and $https) { $base = 'https://'.substr($base, 7); @@ -78,18 +69,13 @@ public static function to_route($name, $parameters = array(), $https = false) { if ( ! is_null($route = Route\Finder::find($name))) { - // ---------------------------------------------------- // Get the first URI assigned to the route. - // ---------------------------------------------------- $uris = explode(', ', key($route)); $uri = substr($uris[0], strpos($uris[0], '/')); - // ---------------------------------------------------- - // Replace any parameters in the URI. This allows - // the dynamic creation of URLs that contain parameter - // wildcards. - // ---------------------------------------------------- + // Replace any parameters in the URI. This allows the dynamic creation of URLs + // that contain parameter wildcards. foreach ($parameters as $parameter) { $uri = preg_replace('/\(.+?\)/', $parameter, $uri, 1); @@ -122,16 +108,10 @@ public static function to_secure_route($name, $parameters = array()) */ public static function slug($title, $separator = '-') { - // ---------------------------------------------------- - // Remove all characters that are not the separator, - // letters, numbers, or whitespace. - // ---------------------------------------------------- + // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', Str::lower($title)); - // ---------------------------------------------------- - // Replace all separator characters and whitespace by - // a single separator - // ---------------------------------------------------- + // Replace all separator characters and whitespace by a single separator $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); return trim($title, $separator); @@ -144,17 +124,13 @@ public static function __callStatic($method, $parameters) { $parameters = (isset($parameters[0])) ? $parameters[0] : array(); - // ---------------------------------------------------- // Dynamically create a secure route URL. - // ---------------------------------------------------- if (strpos($method, 'to_secure_') === 0) { return static::to_route(substr($method, 10), $parameters, true); } - // ---------------------------------------------------- // Dynamically create a route URL. - // ---------------------------------------------------- if (strpos($method, 'to_') === 0) { return static::to_route(substr($method, 3), $parameters);