ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
BasicScalarValueFactory.php
Go to the documentation of this file.
1
<?
php
2
3
namespace
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues
;
4
5
use
ILIAS\BackgroundTasks\Exceptions\InvalidArgumentException
;
6
use
ILIAS\BackgroundTasks\Value
;
7
8
trait
BasicScalarValueFactory
9
{
10
16
protected
function
boolean($bool)
17
{
18
$value =
new
BooleanValue
();
19
$value->setValue($bool);
20
21
return
$value;
22
}
23
24
30
protected
function
float($float)
31
{
32
$value =
new
FloatValue
();
33
$value->setValue($float);
34
35
return
$value;
36
}
37
38
44
protected
function
integer($integer)
45
{
46
$value =
new
IntegerValue
();
47
$value->setValue($integer);
48
49
return
$value;
50
}
51
52
58
protected
function
string($string)
59
{
60
$value =
new
StringValue
();
61
$value->setValue($string);
62
63
return
$value;
64
}
65
66
75
protected
function
wrapValue($value)
76
{
77
// It's already a Value. We don't need to wrap it.
78
if
($value instanceof
Value
) {
79
return
$value;
80
}
81
82
if
(is_scalar($value)) {
83
return
$this->wrapScalar($value);
84
}
85
86
throw
new
InvalidArgumentException
(
"The given parameter is not a Background Task Value and cannot be wrapped in a Background Task Value: "
87
. var_export($value,
true
));
88
}
89
90
96
protected
function
scalar($scalar)
97
{
98
$value =
new
ScalarValue
();
99
$value->setValue($scalar);
100
101
return
$value;
102
}
103
104
111
protected
function
wrapScalar($value)
112
{
113
if
(is_string($value)) {
114
return
$this->string($value);
115
}
116
if
(is_bool($value)) {
117
return
$this->boolean($value);
118
}
119
if
(is_integer($value)) {
120
return
$this->integer($value);
121
}
122
if
(is_float($value)) {
123
return
$this->float($value);
124
}
125
if
(is_scalar($value)) {
126
return
$this->scalar($value);
127
}
128
throw
new
InvalidArgumentException
(
"The given value "
. var_export($value,
true
)
129
.
" is not a scalar and cannot be wrapped."
);
130
}
131
}
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues
Created by PhpStorm.
Definition:
BasicScalarValueFactory.php:3
InvalidArgumentException
BasicScalarValueFactory
ILIAS\BackgroundTasks\Value
Definition:
Value.php:15
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\ScalarValue
Definition:
ScalarValue.php:9
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\IntegerValue
Definition:
IntegerValue.php:7
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BooleanValue
Definition:
BooleanValue.php:5
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\FloatValue
Definition:
FloatValue.php:5
php
InvalidArgumentException
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue
Definition:
StringValue.php:7
Value
src
BackgroundTasks
Implementation
Values
ScalarValues
BasicScalarValueFactory.php
Generated on Thu Jan 16 2025 19:02:36 for ILIAS by
1.8.13 (using
Doxyfile
)