lainchan/inc/lib/Twig/Markup.php

38 lines
764 B
PHP
Raw Normal View History

2011-10-05 00:22:53 -04:00
<?php
/*
* This file is part of Twig.
*
* (c) 2010 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Marks a content as safe.
*
2013-08-01 15:20:12 -04:00
* @author Fabien Potencier <fabien@symfony.com>
2011-10-05 00:22:53 -04:00
*/
2013-08-01 15:20:12 -04:00
class Twig_Markup implements Countable
2011-10-05 00:22:53 -04:00
{
protected $content;
2013-08-01 15:20:12 -04:00
protected $charset;
2011-10-05 00:22:53 -04:00
2013-08-01 15:20:12 -04:00
public function __construct($content, $charset)
2011-10-05 00:22:53 -04:00
{
$this->content = (string) $content;
2013-08-01 15:20:12 -04:00
$this->charset = $charset;
2011-10-05 00:22:53 -04:00
}
public function __toString()
{
return $this->content;
}
2013-08-01 15:20:12 -04:00
public function count()
{
return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
}
2011-10-05 00:22:53 -04:00
}