ILIAS
trunk Revision v11.0_alpha-1713-gd8962da2f67
◀ 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
Marshal.php
Go to the documentation of this file.
1
<?php
2
19
declare(strict_types=1);
20
21
namespace
ILIAS\LegalDocuments\ConsumerToolbox
;
22
23
use
ILIAS\Refinery\Transformation
;
24
use
ILIAS\Refinery\Factory
as
Refinery
;
25
use
DateTimeImmutable
;
26
use
Closure
;
27
use
Exception
;
28
29
class
Marshal
30
{
31
public
function
__construct
(
private
readonly
Refinery
$refinery
)
32
{
33
}
34
35
public
function
dateTime
():
Convert
36
{
37
$from = $this->
refinery
->in()->series([
38
$this->
custom
(fn(
string
$s) =>
'@'
. ($s ?:
'0'
)),
39
$this->
refinery
->to()->dateTime(),
40
]);
41
42
$to = $this->
custom
(fn(
DateTimeImmutable
$x) => (
string
) $x->getTimeStamp());
43
44
return
new
Convert
($from, $to);
45
}
46
47
public
function
boolean
():
Convert
48
{
49
// kindlyTo()->bool() doesn't count an empty string as `false`:
50
$from = $this->
refinery
->byTrying([
51
$this->
refinery
->kindlyTo()->bool(),
52
$this->
custom
(fn(
string
$s):
bool
=> !($s ===
''
|| $this->
error
(
'Value could not be transformed to bool.'
)))
53
]);
54
55
$to = $this->
refinery
->kindlyTo()->string();
56
57
return
new
Convert
($from, $to);
58
}
59
60
public
function
nullable
(
Convert
$convert):
Convert
61
{
62
$from = $this->
refinery
->byTrying([
63
$this->
refinery
->kindlyTo()->null(),
64
$convert->
fromString
(),
65
]);
66
67
$to = $this->
refinery
->byTrying([
68
$this->
refinery
->in()->series([$this->
refinery
->null(), $this->
refinery
->always(
''
)]),
69
$convert->
toString
(),
70
]);
71
72
return
new
Convert
($from, $to);
73
}
74
75
public
function
string
():
Convert
76
{
77
return
new
Convert
(
78
$this->
refinery
->identity(),
79
$this->
refinery
->identity()
80
);
81
}
82
83
private
function
custom
(
Closure
$map):
Transformation
84
{
85
return
$this->
refinery
->custom()->transformation($map);
86
}
87
88
private
function
error
(
string
$message
): void
89
{
90
throw
new
Exception
($message);
91
}
92
}
ILIAS\UI\examples\Layout\Page\Standard\$refinery
$refinery
Definition:
ui.php:137
DateTimeImmutable
Closure
Transformation
ILIAS\LegalDocuments\ConsumerToolbox\Convert\toString
toString()
Definition:
Convert.php:38
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\boolean
boolean()
Definition:
Marshal.php:47
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\string
string()
Definition:
Marshal.php:75
ILIAS\Repository\refinery
refinery()
Definition:
trait.GlobalDICDomainServices.php:76
ILIAS\LegalDocuments\ConsumerToolbox\Marshal
Definition:
Marshal.php:29
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\nullable
nullable(Convert $convert)
Definition:
Marshal.php:60
Factory
ILIAS\LegalDocuments\ConsumerToolbox
Definition:
Blocks.php:21
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\__construct
__construct(private readonly Refinery $refinery)
Definition:
Marshal.php:31
ILIAS\LegalDocuments\ConsumerToolbox\Convert\fromString
fromString()
Definition:
Convert.php:33
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\custom
custom(Closure $map)
Definition:
Marshal.php:83
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\error
error(string $message)
Definition:
Marshal.php:88
ILIAS\LegalDocuments\ConsumerToolbox\Marshal\dateTime
dateTime()
Definition:
Marshal.php:35
ILIAS\Refinery\Transformation
A transformation is a function from one datatype to another.
Definition:
Transformation.php:34
$message
$message
Definition:
xapiexit.php:31
ILIAS\LegalDocuments\ConsumerToolbox\Convert
Definition:
Convert.php:25
Exception
components
ILIAS
LegalDocuments
classes
ConsumerToolbox
Marshal.php
Generated on Fri Apr 4 2025 23:03:25 for ILIAS by
1.8.13 (using
Doxyfile
)