Firestore/src/WriteBatch.php
private function validatePrecondition(array &$options)
    {
        $precondition = isset($options['precondition'])
            ? $options['precondition']
            : null;

        if (!$precondition) {
            return;
        }

        if (isset($precondition['exists'])) {
            return $precondition;
        }

        if (isset($precondition['updateTime'])) {
            if (!($precondition['updateTime'] instanceof Timestamp)) {
                throw new \InvalidArgumentException(
                    'Precondition Update Time must be an instance of `Google\\Cloud\\Core\\Timestamp`'
                );
            }

            return [
                'updateTime' => $precondition['updateTime']->formatForApi()
            ];
        }

        throw new \InvalidArgumentException('Preconditions must provide either `exists` or `updateTime`.');
    }
private function validatePrecondition(array &$options)
    {
        $precondition = isset($options['precondition'])
            ? $options['precondition']
            : null;

        if (!$precondition) {
            return;
        }

        if (isset($precondition['exists'])) {
            return $precondition;
        }

        if (isset($precondition['updateTime'])) {
            if (!($precondition['updateTime'] instanceof Timestamp)) {
                throw new \InvalidArgumentException(
                    'Precondition Update Time must be an instance of `Google\\Cloud\\Core\\Timestamp`'
                );
            }

            return [
                'updateTime' => $precondition['updateTime']->formatForApi()
            ];
        }

        throw new \InvalidArgumentException('Preconditions must provide either `exists` or `updateTime`.');
    }
private function validatePrecondition ( array & $ options ) { $ precondition = isset ( $ options [ 'precondition' ] ) ? $ options [ 'precondition' ] : null ; if ( ! $ precondition ) { return ; } if ( isset ( $ precondition [ 'exists' ] ) ) { return $ precondition ; } if ( isset ( $ precondition [ 'updateTime' ] ) ) { if ( ! ( $ precondition [ 'updateTime' ] instanceof Timestamp ) ) { throw new \ InvalidArgumentException ( 'Precondition Update Time must be an instance of `Google\\Cloud\\Core\\Timestamp`' ) ; } return [ 'updateTime' => $ precondition [ 'updateTime' ] -> formatForApi ( ) ] ; } throw new \ InvalidArgumentException ( 'Preconditions must provide either `exists` or `updateTime`.' ) ; }
Validates a document precondition, if set.

@codingStandardsIgnoreStart
@param array $options Configuration Options
@return array [Precondition](https://firebase.google.com/docs/firestore/reference/rpc/google.firestore.v1beta1#google.firestore.v1beta1.Precondition)
@throws \InvalidArgumentException If the precondition is invalid.
@codingStandardsIgnoreEnd
Validates a document precondition if set .