ILIAS
trunk Revision v11.0_alpha-1749-g1a06bdef097
◀ ilDoc Overview
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Variables
$
c
e
g
h
j
l
m
p
s
t
u
v
+
Enumerations
a
c
e
f
i
j
l
m
n
o
p
r
s
t
u
v
z
+
Enumerator
a
c
d
e
f
g
i
l
m
n
o
p
q
s
t
u
v
y
+
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
+
Data Fields
+
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Ö
Enumerations
Enumerator
+
Files
File List
+
Globals
+
All
$
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
z
+
Functions
a
b
c
d
e
f
g
h
i
m
n
p
r
s
t
u
v
+
Variables
$
a
c
e
g
h
i
m
n
o
p
r
s
t
u
v
z
Enumerations
Enumerator
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Modules
Pages
StringTransformation.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\Refinery\KindlyTo\Transformation
;
22
23
use
ILIAS\Refinery\DeriveApplyToFromTransform
;
24
use
ILIAS\Refinery\DeriveInvokeFromTransform
;
25
use
ILIAS\Refinery\Transformation
;
26
use
ILIAS\Refinery\ConstraintViolationException
;
27
28
class
StringTransformation
implements
Transformation
29
{
30
use
DeriveApplyToFromTransform
;
31
use
DeriveInvokeFromTransform
;
32
private
const
BOOL_TRUE
=
true
;
33
private
const
BOOL_FALSE
=
false
;
34
private
const
BOOL_TRUE_NUMBER
= 1;
35
private
const
BOOL_FALSE_NUMBER
= 0;
36
private
const
BOOL_TRUE_STRING
=
'true'
;
37
private
const
BOOL_FALSE_STRING
=
'false'
;
38
42
public
function
transform
($from): string
43
{
44
if
(is_int($from) || is_float($from)) {
45
return
(
string
) $from;
46
}
47
48
if
(is_bool($from) || $from === self::BOOL_TRUE_NUMBER || $from === self::BOOL_FALSE_NUMBER) {
49
if
($from === self::BOOL_TRUE || $from === self::BOOL_TRUE_NUMBER) {
50
return
self::BOOL_TRUE_STRING;
51
}
52
if
($from === self::BOOL_FALSE || $from === self::BOOL_FALSE_NUMBER) {
53
return
self::BOOL_FALSE_STRING;
54
}
55
}
56
57
if
(is_string($from)) {
58
return
$from;
59
}
60
61
if
(is_object($from) && method_exists($from,
'__toString'
)) {
62
return
(
string
) $from;
63
}
64
65
throw
new
ConstraintViolationException
(
66
sprintf(
'The value "%s" could not be transformed into a string'
, var_export($from,
true
)),
67
'not_string'
,
68
$from
69
);
70
}
71
}
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation
Definition:
StringTransformation.php:28
ILIAS\Refinery\DeriveInvokeFromTransform
trait DeriveInvokeFromTransform
Definition:
DeriveInvokeFromTransform.php:24
ILIAS\Refinery\DeriveApplyToFromTransform
trait DeriveApplyToFromTransform
Definition:
DeriveApplyToFromTransform.php:29
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_FALSE_NUMBER
const BOOL_FALSE_NUMBER
Definition:
StringTransformation.php:35
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_FALSE_STRING
const BOOL_FALSE_STRING
Definition:
StringTransformation.php:37
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_TRUE_STRING
const BOOL_TRUE_STRING
Definition:
StringTransformation.php:36
Transformation
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_FALSE
const BOOL_FALSE
Definition:
StringTransformation.php:33
ILIAS\Refinery\ConstraintViolationException
Definition:
ConstraintViolationException.php:29
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_TRUE
const BOOL_TRUE
Definition:
StringTransformation.php:32
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\BOOL_TRUE_NUMBER
const BOOL_TRUE_NUMBER
Definition:
StringTransformation.php:34
ILIAS\Refinery\Transformation
A transformation is a function from one datatype to another.
Definition:
Transformation.php:34
ILIAS\Refinery\KindlyTo\Transformation\StringTransformation\transform
transform($from)
Definition:
StringTransformation.php:42
ConstraintViolationException
ILIAS\Refinery\KindlyTo\Transformation
Definition:
BooleanTransformation.php:21
components
ILIAS
Refinery
src
KindlyTo
Transformation
StringTransformation.php
Generated on Wed Apr 9 2025 23:03:48 for ILIAS by
1.8.13 (using
Doxyfile
)