public function valueObject($value, $exclude = false, $meaning = null)
{
switch (gettype($value)) {
case 'boolean':
$propertyValue = ['booleanValue' => $value];
break;
case 'integer':
$propertyValue = ['integerValue' => $value];
break;
case 'double':
$propertyValue = ['doubleValue' => $value];
break;
case 'string':
$propertyValue = ['stringValue' => $value];
break;
case 'array':
if (!empty($value) && $this->isAssoc($value)) {
$propertyValue = $this->convertArrayToEntityValue($value);
} else {
$propertyValue = $this->convertArrayToArrayValue($value);
}
break;
case 'object':
$propertyValue = $this->objectProperty($value);
break;
case 'resource':
$content = stream_get_contents($value);
$propertyValue = ['blobValue' => $this->encode ? base64_encode($content) : $content];
break;
case 'NULL':
$propertyValue = ['nullValue' => null];
break;
//@codeCoverageIgnoreStart
//@codeCoverageIgnoreStart
case 'unknown type':
throw new InvalidArgumentException(sprintf('Unknown type for `%s', $content));
break;
default:
throw new InvalidArgumentException(sprintf('Invalid type for `%s', $content));
break;
//@codeCoverageIgnoreEnd
}
if ($exclude) {
$propertyValue['excludeFromIndexes'] = true;
}
if ($meaning) {
$propertyValue['meaning'] = $meaning;
}
return $propertyValue;
}