Google\Cloud\NaturalLanguage\NaturalLanguageClient::formatRequest PHP Method

formatRequest() private method

Formats the request for the API.
private formatRequest ( string | StorageObject $content, array $options ) : array
$content string | Google\Cloud\Storage\StorageObject The content to analyze.
$options array [optional] Configuration Options.
return array
    private function formatRequest($content, array $options)
    {
        $docOptions = ['type', 'language', 'content', 'gcsContentUri'];
        $options += ['encodingType' => 'UTF8', 'type' => 'PLAIN_TEXT'];
        if ($content instanceof StorageObject) {
            $objIdentity = $content->identity();
            $options['gcsContentUri'] = 'gs://' . $objIdentity['bucket'] . '/' . $objIdentity['object'];
        } else {
            $options['content'] = $content;
        }
        foreach ($options as $option => $value) {
            if (in_array($option, $docOptions)) {
                $options['document'][$option] = $value;
                unset($options[$option]);
            }
        }
        return $options;
    }