Google\Cloud\Datastore\EntityMapper::objectProperty PHP Method

objectProperty() public method

Convert different object types to API values
public objectProperty ( mixed $value ) : array
$value mixed The value object
return array
    public function objectProperty($value)
    {
        switch (true) {
            case $value instanceof Int64:
                return ['integerValue' => $value->get()];
                break;
            case $value instanceof Blob:
                return ['blobValue' => $this->encode ? base64_encode((string) $value) : (string) $value];
                break;
            case $value instanceof \DateTimeInterface:
                return ['timestampValue' => $value->format(self::DATE_FORMAT)];
                break;
            case $value instanceof Entity:
                return ['entityValue' => $this->objectToRequest($value)];
                break;
            case $value instanceof GeoPoint:
                return ['geoPointValue' => $value->point()];
                break;
            case $value instanceof Key:
                return ['keyValue' => $value->keyObject()];
                break;
            default:
                throw new InvalidArgumentException(sprintf('Value of type `%s` could not be serialized', get_class($value)));
                break;
        }
    }