24trait BasicScalarValueFactory
29 $value->setValue($bool);
34 protected function float(
float $float): FloatValue
36 $value =
new FloatValue();
37 $value->setValue($float);
42 protected function integer(
int $integer): IntegerValue
44 $value =
new IntegerValue();
45 $value->setValue($integer);
50 protected function string(
string $string): StringValue
52 $value =
new StringValue();
53 $value->setValue($string);
63 protected function wrapValue($value): Value
66 if ($value instanceof Value) {
70 if (is_scalar($value)) {
71 return $this->wrapScalar($value);
74 throw new InvalidArgumentException(
"The given parameter is not a Background Task Value and cannot be wrapped in a Background Task Value: "
75 . var_export($value,
true));
81 protected function scalar($scalar): ScalarValue
83 $value =
new ScalarValue();
84 $value->setValue($scalar);
93 protected function wrapScalar($value): Value
95 if (is_string($value)) {
96 return $this->string($value);
98 if (is_bool($value)) {
99 return $this->boolean($value);
101 if (is_int($value)) {
102 return $this->integer($value);
104 if (is_float($value)) {
105 return $this->float($value);
107 if (is_scalar($value)) {
108 return $this->scalar($value);
110 throw new InvalidArgumentException(
"The given value " . var_export($value,
true)
111 .
" is not a scalar and cannot be wrapped.");
Class Exception Thrown if some procedure did not get the arguments it expected.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...