ILIAS
release_8 Revision v8.23
◀ ilDoc Overview
FloatTransformation.php
Go to the documentation of this file.
1
<?php
2
3
declare(strict_types=1);
4
21
namespace
ILIAS\Refinery\To\Transformation
;
22
23
use
ILIAS\Refinery\DeriveApplyToFromTransform
;
24
use
ILIAS\Refinery\Constraint
;
25
use
ILIAS\Refinery\DeriveInvokeFromTransform
;
26
use
ILIAS\Refinery\ProblemBuilder
;
27
use
UnexpectedValueException
;
28
29
class
FloatTransformation
implements
Constraint
30
{
31
use
DeriveApplyToFromTransform
;
32
use
DeriveInvokeFromTransform
;
33
use
ProblemBuilder
;
34
38
public
function
transform
($from): float
39
{
40
$this->
check
($from);
41
return
(
float
) $from;
42
}
43
47
public
function
getError
(): string
48
{
49
return
'The value MUST be of type string.'
;
50
}
51
55
public
function
check
($value)
56
{
57
if
(!$this->
accepts
($value)) {
58
throw
new
UnexpectedValueException
($this->
getErrorMessage
($value));
59
}
60
61
return
null;
62
}
63
67
public
function
accepts
($value): bool
68
{
69
return
is_float($value);
70
}
71
75
public
function
problemWith
($value): ?string
76
{
77
if
(!$this->
accepts
($value)) {
78
return
$this->
getErrorMessage
($value);
79
}
80
81
return
null;
82
}
83
}
ILIAS\Refinery\To\Transformation\FloatTransformation\transform
transform($from)
Definition:
FloatTransformation.php:38
ILIAS\Refinery\To\Transformation\FloatTransformation
Definition:
FloatTransformation.php:29
ILIAS\Refinery\Constraint
A constraint encodes some resrtictions on values.
Definition:
Constraint.php:31
ILIAS\Refinery\ProblemBuilder
trait ProblemBuilder
Definition:
ProblemBuilder.php:27
ILIAS\Refinery\DeriveApplyToFromTransform
trait DeriveApplyToFromTransform
Definition:
DeriveApplyToFromTransform.php:29
ILIAS\Refinery\To\Transformation\FloatTransformation\problemWith
problemWith($value)
Definition:
FloatTransformation.php:75
ILIAS\Refinery\To\Transformation
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition:
BooleanTransformation.php:21
UnexpectedValueException
ILIAS\Refinery\DeriveInvokeFromTransform
trait DeriveInvokeFromTransform
Definition:
DeriveInvokeFromTransform.php:27
ILIAS\Refinery\getErrorMessage
getErrorMessage($value)
Get the problem message.
Definition:
ProblemBuilder.php:48
ILIAS\Refinery\To\Transformation\FloatTransformation\accepts
accepts($value)
Definition:
FloatTransformation.php:67
ILIAS\Refinery\To\Transformation\FloatTransformation\getError
getError()
Definition:
FloatTransformation.php:47
Constraint
ILIAS\Refinery\To\Transformation\FloatTransformation\check
check($value)
Definition:
FloatTransformation.php:55
src
Refinery
To
Transformation
FloatTransformation.php
Generated on Wed Sep 3 2025 22:02:55 for ILIAS by
1.8.13 (using
Doxyfile
)