<?php
 namespace Eluceo\iCal\Presentation\Component\Property\Value; use Eluceo\iCal\Presentation\Component\Property\Value; class TextValue extends Value { private const ESCAPED_CHARACTERS = [ '\\' => '\\\\', ';' => '\\;', ',' => '\\,', "\n" => '\\n', '\\\\n' => '\\n', ]; private const FORBIDDEN_CHARACTERS = [ "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\x09", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f", "\x7f", ]; private string $value; public function __construct(string $value) { $this->value = $value; } public function __toString(): string { $value = $this->value; $value = str_replace(array_keys(self::ESCAPED_CHARACTERS), array_values(self::ESCAPED_CHARACTERS), $value); $value = str_replace(self::FORBIDDEN_CHARACTERS, '', $value); return $value; } } 