ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
HTMLSpecialCharsAsEntities.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use 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.