ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
FromSvgTransformation.php
Go to the documentation of this file.
1<?php
2
18declare(strict_types=1);
19
21
26
32{
35
36 protected const string SCHEME = 'data:';
37 protected const string MIME_TYPE = 'image/svg+xml';
38 protected const string ENCODING = 'base64';
39
40 public function transform(mixed $from): string
41 {
42 if (!$from instanceof SVG) {
43 throw new \InvalidArgumentException("Argument must be of type " . SVG::class);
44 }
45
46 return self::SCHEME . self::MIME_TYPE . ';' . self::ENCODING . ',' . base64_encode($from->__toString());
47 }
48}
Data transfer object that carries the raw SVG data as a string, created from trusted sources.
Definition: SVG.php:30
A transformation is a function from one datatype to another.