ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\ConsumerToolbox\Marshal Class Reference
+ Collaboration diagram for ILIAS\LegalDocuments\ConsumerToolbox\Marshal:

Public Member Functions

 __construct (private readonly Refinery $refinery)
 
 dateTime ()
 
 boolean ()
 
 nullable (Convert $convert)
 
 string ()
 

Private Member Functions

 custom (Closure $map)
 
 error (string $message)
 

Detailed Description

Definition at line 29 of file Marshal.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::__construct ( private readonly Refinery  $refinery)

Definition at line 31 of file Marshal.php.

32 {
33 }

Member Function Documentation

◆ boolean()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::boolean ( )

Definition at line 47 of file Marshal.php.

47 : 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 }

References ILIAS\LegalDocuments\ConsumerToolbox\Marshal\error(), and ILIAS\Repository\refinery().

Referenced by ILIAS\DataProtection\Settings\boolean(), ILIAS\TermsOfService\Settings\boolean(), ILIAS\DataProtection\UserSettings\withdrawalRequested(), and ILIAS\TermsOfService\UserSettings\withdrawalRequested().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ custom()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::custom ( Closure  $map)
private

Definition at line 83 of file Marshal.php.

83 : Transformation
84 {
85 return $this->refinery->custom()->transformation($map);
86 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Marshal\dateTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dateTime()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::dateTime ( )

Definition at line 35 of file Marshal.php.

35 : 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 }

References ILIAS\LegalDocuments\ConsumerToolbox\Marshal\custom(), and ILIAS\Repository\refinery().

Referenced by ILIAS\DataProtection\UserSettings\agreeDate(), ILIAS\DataProtection\Settings\lastResetDate(), and ILIAS\TermsOfService\Settings\lastResetDate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ error()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::error ( string  $message)
private

Definition at line 88 of file Marshal.php.

88 : void
89 {
90 throw new Exception($message);
91 }
$message
Definition: xapiexit.php:31

References $message.

Referenced by ILIAS\LegalDocuments\ConsumerToolbox\Marshal\boolean().

+ Here is the caller graph for this function:

◆ nullable()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::nullable ( Convert  $convert)

Definition at line 60 of file Marshal.php.

60 : 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 }

References ILIAS\LegalDocuments\ConsumerToolbox\Convert\fromString(), ILIAS\Repository\refinery(), and ILIAS\LegalDocuments\ConsumerToolbox\Convert\toString().

Referenced by ILIAS\DataProtection\UserSettings\agreeDate(), and ILIAS\LegalDocuments\ConsumerToolbox\Routing\originalTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ string()

ILIAS\LegalDocuments\ConsumerToolbox\Marshal::string ( )

Definition at line 75 of file Marshal.php.

75 : Convert
76 {
77 return new Convert(
78 $this->refinery->identity(),
79 $this->refinery->identity()
80 );
81 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\DataProtection\Settings\adminEmail(), ILIAS\TermsOfService\Settings\adminEmail(), ILIAS\DataProtection\Settings\authMode(), ILIAS\TermsOfService\Settings\authMode(), and ILIAS\LegalDocuments\ConsumerToolbox\Routing\originalTarget().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: