From 49d9666958461914c5af4e3a42a6e196fa197bc4 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 16 Feb 2012 13:59:48 -0600 Subject: [PATCH] final code cleanup --- laravel/bundle.php | 6 +++--- laravel/config.php | 2 +- laravel/cookie.php | 47 ++++++++++++++++++++++++++++------------------ 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/laravel/bundle.php b/laravel/bundle.php index 462cd905..0336cfb8 100644 --- a/laravel/bundle.php +++ b/laravel/bundle.php @@ -81,9 +81,9 @@ public static function start($bundle) throw new \Exception("Bundle [$bundle] has not been installed."); } - // Each bundle may have a "start" script which is responsible for preparing - // the bundle for use by the application. The start script may register any - // classes the bundle uses with the auto-loader, etc. + // Each bundle may have a start script which is responsible for preparing + // the bundle for use by the application. The start script may register + // any classes the bundle uses with the auto-loader, etc. if (file_exists($path = static::path($bundle).'start'.EXT)) { require $path; diff --git a/laravel/config.php b/laravel/config.php index dc7ed806..fc5e0895 100644 --- a/laravel/config.php +++ b/laravel/config.php @@ -141,7 +141,7 @@ protected static function parse($key) // If there are not at least two segments in the array, it means that the // developer is requesting the entire configuration array to be returned. - // If that is the case, we'll make the item field of the array "null". + // If that is the case, we'll make the item field "null". if (count($segments) >= 2) { $parsed = array($bundle, $segments[0], implode('.', array_slice($segments, 1))); diff --git a/laravel/cookie.php b/laravel/cookie.php index bbf72042..c3660642 100644 --- a/laravel/cookie.php +++ b/laravel/cookie.php @@ -31,29 +31,40 @@ public static function send() { if (headers_sent()) return false; - // All cookies are stored in the "jar" when set and not sent directly to - // the browser. This simply makes testing all of the cookie stuff very - // easy since the jar can be inspected by the tests. + // All cookies are stored in the "jar" when set and not sent directly to the + // browser. This simply makes testing all of the cookie stuff very easy + // since the jar can be inspected by the tests. foreach (static::$jar as $cookie) { - extract($cookie); - - $time = ($minutes !== 0) ? time() + ($minutes * 60) : 0; - - // A cookie payload can't exceed 4096 bytes, so if the payload is greater - // than that, we'll raise an error to warn the developer since it could - // cause serious session problems. - $value = static::sign($name, $value); - - if (strlen($value) > 4000) - { - throw new \Exception("Payload too large for cookie."); - } - - setcookie($name, $value, $time, $path, $domain, $secure); + static::set($cookie); } } + /** + * Send a cookie from the cookie jar back to the browser. + * + * @param array $cookie + * @return void + */ + protected static function set($cookie) + { + extract($cookie); + + $time = ($minutes !== 0) ? time() + ($minutes * 60) : 0; + + // A cookie payload can't exceed 4096 bytes, so if the payload is greater + // than that, we'll raise an error to warn the developer since it could + // cause serious cookie-based session problems. + $value = static::sign($name, $value); + + if (strlen($value) > 4000) + { + throw new \Exception("Payload too large for cookie."); + } + + setcookie($name, $value, $time, $path, $domain, $secure); + } + /** * Get the value of a cookie. *