Optimize Str-helper (see pull request #1180)

Signed-off-by: Bryan te Beek <bryantebeek@gmail.com>
This commit is contained in:
Bryan te Beek 2012-09-10 21:11:20 +02:00
parent 1f005bd7e5
commit 01ba355787
1 changed files with 16 additions and 11 deletions

View File

@ -10,15 +10,20 @@ class Str {
public static $pluralizer; public static $pluralizer;
/** /**
* Get the default string encoding for the application. * Cache application encoding locally to save expensive calls to Config::get().
* *
* This method is simply a short-cut to Config::get('application.encoding'). * @var string
*/
public static $encoding = null;
/**
* Get the appliction.encoding without needing to request it from Config::get() each time.
* *
* @return string * @return string
*/ */
public static function encoding() protected static function encoding()
{ {
return Config::get('application.encoding'); return static::$encoding ?: static::$encoding = Config::get('application.encoding');
} }
/** /**