ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
HTMLSpecialCharsAsEntities.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 use ValueError;
27 
38 {
41 
42  public function transform($from)
43  {
44  if (false === preg_match('//u', $from)) {
45  throw new ValueError('Invalid UTF-8 string given.');
46  }
47  return htmlspecialchars($from, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
48  }
49 }
Inspired by: Laminas escaper: https://github.com/laminas/laminas-escaper.
A transformation is a function from one datatype to another.