private function _validate_and_normalize_metadata($metadata)
    {
        $metadata_copy = [];
        foreach ($metadata as $key => $value) {
            if (!preg_match('/^[A-Za-z\d_-]+$/', $key)) {
                throw new \InvalidArgumentException(
                    'Metadata keys must be nonempty strings containing only '.
                    'alphanumeric characters, hyphens and underscores'
                );
            }
            $metadata_copy[strtolower($key)] = $value;
        }

        return $metadata_copy;
    }
private function _validate_and_normalize_metadata($metadata)
    {
        $metadata_copy = [];
        foreach ($metadata as $key => $value) {
            if (!preg_match('/^[A-Za-z\d_-]+$/', $key)) {
                throw new \InvalidArgumentException(
                    'Metadata keys must be nonempty strings containing only '.
                    'alphanumeric characters, hyphens and underscores'
                );
            }
            $metadata_copy[strtolower($key)] = $value;
        }

        return $metadata_copy;
    }
private function _validate_and_normalize_metadata ( $ metadata ) { $ metadata_copy = [ ] ; foreach ( $ metadata as $ key => $ value ) { if ( ! preg_match ( '/^[A-Za-z\d_-]+$/' , $ key ) ) { throw new \ InvalidArgumentException ( 'Metadata keys must be nonempty strings containing only ' . 'alphanumeric characters, hyphens and underscores' ) ; } $ metadata_copy [ strtolower ( $ key ) ] = $ value ; } return $ metadata_copy ; }
validate and normalize the metadata array.

@param array $metadata The metadata map

@return array $metadata Validated and key-normalized metadata map
@throw InvalidArgumentException if key contains invalid characters
validate and normalize the metadata array .