summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Markup.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/lib/Twig/Markup.php')
-rw-r--r--inc/lib/Twig/Markup.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/inc/lib/Twig/Markup.php b/inc/lib/Twig/Markup.php
index c1a1469c..69871fcb 100644
--- a/inc/lib/Twig/Markup.php
+++ b/inc/lib/Twig/Markup.php
@@ -12,20 +12,26 @@
/**
* Marks a content as safe.
*
- * @package twig
- * @author Fabien Potencier <fabien@symfony.com>
+ * @author Fabien Potencier <fabien@symfony.com>
*/
-class Twig_Markup
+class Twig_Markup implements Countable
{
protected $content;
+ protected $charset;
- public function __construct($content)
+ public function __construct($content, $charset)
{
$this->content = (string) $content;
+ $this->charset = $charset;
}
public function __toString()
{
return $this->content;
}
+
+ public function count()
+ {
+ return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
+ }
}