8trait BasicScalarValueFactory
16 protected function boolean($bool)
19 $value->setValue($bool);
30 protected function float($float)
32 $value =
new FloatValue();
33 $value->setValue($float);
44 protected function integer($integer)
46 $value =
new IntegerValue();
47 $value->setValue($integer);
58 protected function string($string)
60 $value =
new StringValue();
61 $value->setValue($string);
75 protected function wrapValue($value)
78 if ($value instanceof Value) {
82 if (is_scalar($value)) {
83 return $this->wrapScalar($value);
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));
96 protected function scalar($scalar)
98 $value =
new ScalarValue();
99 $value->setValue($scalar);
111 protected function wrapScalar($value)
113 if (is_string($value)) {
114 return $this->string($value);
116 if (is_bool($value)) {
117 return $this->boolean($value);
119 if (is_integer($value)) {
120 return $this->integer($value);
122 if (is_float($value)) {
123 return $this->float($value);
125 if (is_scalar($value)) {
126 return $this->scalar($value);
128 throw new InvalidArgumentException(
"The given value " . var_export($value,
true)
129 .
" is not a scalar and cannot be wrapped.");
An exception for terminatinating execution or to throw for unit testing.