Commit a9be66d4 by thybag

Refactor changes into single get_encoding() method within the HTML Class (in…

Refactor changes into single get_encoding() method within the HTML Class (in order to remove duplication of logic). All tests continue to pass.
parent 6e44b408
...@@ -38,8 +38,7 @@ class HTML { ...@@ -38,8 +38,7 @@ class HTML {
*/ */
public static function entities($value) public static function entities($value)
{ {
if(static::$encoding===null) static::$encoding = Config::get('application.encoding'); return htmlentities($value, ENT_QUOTES, static::get_encoding(), false);
return htmlentities($value, ENT_QUOTES, static::$encoding, false);
} }
/** /**
...@@ -50,8 +49,7 @@ class HTML { ...@@ -50,8 +49,7 @@ class HTML {
*/ */
public static function decode($value) public static function decode($value)
{ {
if(static::$encoding===null) static::$encoding = Config::get('application.encoding'); return html_entity_decode($value, ENT_QUOTES, static::get_encoding());
return html_entity_decode($value, ENT_QUOTES, static::$encoding);
} }
/** /**
...@@ -64,8 +62,7 @@ class HTML { ...@@ -64,8 +62,7 @@ class HTML {
*/ */
public static function specialchars($value) public static function specialchars($value)
{ {
if(static::$encoding===null) static::$encoding = Config::get('application.encoding'); return htmlspecialchars($value, ENT_QUOTES, static::get_encoding(), false);
return htmlspecialchars($value, ENT_QUOTES, static::$encoding, false);
} }
/** /**
...@@ -418,6 +415,18 @@ class HTML { ...@@ -418,6 +415,18 @@ class HTML {
} }
/** /**
* Get the appliction.encoding without needing to request it from Config::get() each time.
*
* @return string
*/
public static function get_encoding(){
if(static::$encoding===null) static::$encoding = Config::get('application.encoding');
return static::$encoding;
}
/**
* Dynamically handle calls to custom macros. * Dynamically handle calls to custom macros.
* *
* @param string $method * @param string $method
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment