Bitrix-D7  20.5.0
main/lib/text/converter.php
См. документацию.
1 <?php
2 namespace Bitrix\Main\Text;
3 
4 abstract class Converter
5 {
6  const TEXT = "text";
7  const HTML = "html";
8 
9  private static $htmlConverter;
10  private static $xmlConverter;
11  private static $emptyConverter;
12 
13  public static function getHtmlConverter()
14  {
15  if (self::$htmlConverter == null)
16  self::$htmlConverter = new HtmlConverter();
17  return self::$htmlConverter;
18  }
19 
20  public static function getXmlConverter()
21  {
22  if (self::$xmlConverter == null)
23  self::$xmlConverter = new XmlConverter();
24  return self::$xmlConverter;
25  }
26 
27  public static function getEmptyConverter()
28  {
29  if (self::$emptyConverter == null)
30  self::$emptyConverter = new EmptyConverter();
31  return self::$emptyConverter;
32  }
33 
34  public static function initTextType($textType)
35  {
36  $textType = mb_strtolower($textType);
37  if ($textType != self::TEXT && $textType != self::HTML)
38  $textType = self::TEXT;
39  return $textType;
40  }
41 
42  abstract public function encode($text, $textType = "");
43  abstract public function decode($text, $textType = "");
44 }
encode($text, $textType="")
decode($text, $textType="")