ILIAS
trunk Revision v12.0_alpha-1540-g00f839d5fa1
◀ ilDoc Overview
FromSvgTransformation.php
Go to the documentation of this file.
1
<?php
2
18
declare(strict_types=1);
19
20
namespace
ILIAS\Refinery\URI\Transformation
;
21
22
use
ILIAS\Refinery\DeriveApplyToFromTransform
;
23
use
ILIAS\Refinery\DeriveInvokeFromTransform
;
24
use
ILIAS\Refinery\Transformation
;
25
use
ILIAS\Data\SVG
;
26
31
class
FromSvgTransformation
implements
Transformation
32
{
33
use
DeriveApplyToFromTransform
;
34
use
DeriveInvokeFromTransform
;
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
}
ILIAS\Data\SVG
Data transfer object that carries the raw SVG data as a string, created from trusted sources.
Definition:
SVG.php:30
ILIAS\Refinery\URI\Transformation\FromSvgTransformation
The {.
Definition:
FromSvgTransformation.php:32
ILIAS\Refinery\URI\Transformation\FromSvgTransformation\transform
transform(mixed $from)
Definition:
FromSvgTransformation.php:40
ILIAS\Refinery\URI\Transformation\FromSvgTransformation\MIME_TYPE
const string MIME_TYPE
Definition:
FromSvgTransformation.php:37
ILIAS\Refinery\URI\Transformation\FromSvgTransformation\SCHEME
const string SCHEME
Definition:
FromSvgTransformation.php:36
ILIAS\Refinery\URI\Transformation\FromSvgTransformation\ENCODING
const string ENCODING
Definition:
FromSvgTransformation.php:38
ILIAS\Refinery\DeriveInvokeFromTransform
trait DeriveInvokeFromTransform
Definition:
DeriveInvokeFromTransform.php:24
ILIAS\Refinery\DeriveApplyToFromTransform
trait DeriveApplyToFromTransform
Definition:
DeriveApplyToFromTransform.php:29
ILIAS\Refinery\Transformation
A transformation is a function from one datatype to another.
Definition:
Transformation.php:35
ILIAS\Refinery\URI\Transformation
Definition:
FromSvgTransformation.php:20
components
ILIAS
Refinery
src
URI
Transformation
FromSvgTransformation.php
Generated on Wed Jun 3 2026 23:05:40 for ILIAS by
1.9.4 (using
Doxyfile
)