Firestore/src/ValueMapper.php
private function encodeObjectValue($value)
    {
        if ($value instanceof \stdClass) {
            return $this->encodeAssociativeArrayValue((array) $value);
        }

        if ($value instanceof Blob) {
            return ['bytesValue' => (string) $value];
        }

        if ($value instanceof \DateTimeInterface) {
            return [
                'timestampValue' => [
                    'seconds' => $value->format('U'),
                    'nanos' => (int)($value->format('u') * 1000)
                ]
            ];
        }

        if ($value instanceof Timestamp) {
            return [
                'timestampValue' => [
                    'seconds' => $value->get()->format('U'),
                    'nanos' => $value->nanoSeconds()
                ]
            ];
        }

        if ($value instanceof GeoPoint) {
            return ['geoPointValue' => $value->point()];
        }

        if ($value instanceof DocumentReference || $value instanceof DocumentSnapshot) {
            return ['referenceValue' => $value->name()];
        }

        throw new \RuntimeException(sprintf(
            'Object of type %s cannot be encoded to a Firestore value type.',
            get_class($value)
        ));
    }
private function encodeObjectValue($value)
    {
        if ($value instanceof \stdClass) {
            return $this->encodeAssociativeArrayValue((array) $value);
        }

        if ($value instanceof Blob) {
            return ['bytesValue' => (string) $value];
        }

        if ($value instanceof \DateTimeInterface) {
            return [
                'timestampValue' => [
                    'seconds' => $value->format('U'),
                    'nanos' => (int)($value->format('u') * 1000)
                ]
            ];
        }

        if ($value instanceof Timestamp) {
            return [
                'timestampValue' => [
                    'seconds' => $value->get()->format('U'),
                    'nanos' => $value->nanoSeconds()
                ]
            ];
        }

        if ($value instanceof GeoPoint) {
            return ['geoPointValue' => $value->point()];
        }

        if ($value instanceof DocumentReference || $value instanceof DocumentSnapshot) {
            return ['referenceValue' => $value->name()];
        }

        throw new \RuntimeException(sprintf(
            'Object of type %s cannot be encoded to a Firestore value type.',
            get_class($value)
        ));
    }
private function encodeObjectValue ( $ value ) { if ( $ value instanceof \ stdClass ) { return $ this -> encodeAssociativeArrayValue ( ( array ) $ value ) ; } if ( $ value instanceof Blob ) { return [ 'bytesValue' => ( string ) $ value ] ; } if ( $ value instanceof \ DateTimeInterface ) { return [ 'timestampValue' => [ 'seconds' => $ value -> format ( 'U' ) , 'nanos' => ( int ) ( $ value -> format ( 'u' ) * 1000 ) ] ] ; } if ( $ value instanceof Timestamp ) { return [ 'timestampValue' => [ 'seconds' => $ value -> get ( ) -> format ( 'U' ) , 'nanos' => $ value -> nanoSeconds ( ) ] ] ; } if ( $ value instanceof GeoPoint ) { return [ 'geoPointValue' => $ value -> point ( ) ] ; } if ( $ value instanceof DocumentReference || $ value instanceof DocumentSnapshot ) { return [ 'referenceValue' => $ value -> name ( ) ] ; } throw new \ RuntimeException ( sprintf ( 'Object of type %s cannot be encoded to a Firestore value type.' , get_class ( $ value ) ) ) ; }
Encode a value of type `object` as a Firestore value.

@param object $value
@return array
@throws \RuntimeException If an invalid object type is provided.
Encode a value of type object as a Firestore value .