private function prepareRequestParams(array $data)
    {
        $has_resource = false;
        $multipart = [];

        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $multipart[] = ['name' => $key, 'contents' => $value];
                continue;
            }

            foreach ($value as $multiKey => $multiValue) {
                is_resource($multiValue) && $has_resource = true;
                $multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
                $multipart[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
            }
        }

        if ($has_resource) {
            return ['multipart' => $multipart];
        }

        return ['form_params' => $data];
    }
private function prepareRequestParams(array $data)
    {
        $has_resource = false;
        $multipart = [];

        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $multipart[] = ['name' => $key, 'contents' => $value];
                continue;
            }

            foreach ($value as $multiKey => $multiValue) {
                is_resource($multiValue) && $has_resource = true;
                $multiName = $key . '[' . $multiKey . ']' . (is_array($multiValue) ? '[' . key($multiValue) . ']' : '') . '';
                $multipart[] = ['name' => $multiName, 'contents' => (is_array($multiValue) ? reset($multiValue) : $multiValue)];
            }
        }

        if ($has_resource) {
            return ['multipart' => $multipart];
        }

        return ['form_params' => $data];
    }
private function prepareRequestParams ( array $ data ) { $ has_resource = false ; $ multipart = [ ] ; foreach ( $ data as $ key => $ value ) { if ( ! is_array ( $ value ) ) { $ multipart [ ] = [ 'name' => $ key , 'contents' => $ value ] ; continue ; } foreach ( $ value as $ multiKey => $ multiValue ) { is_resource ( $ multiValue ) && $ has_resource = true ; $ multiName = $ key . '[' . $ multiKey . ']' . ( is_array ( $ multiValue ) ? '[' . key ( $ multiValue ) . ']' : '' ) . '' ; $ multipart [ ] = [ 'name' => $ multiName , 'contents' => ( is_array ( $ multiValue ) ? reset ( $ multiValue ) : $ multiValue ) ] ; } } if ( $ has_resource ) { return [ 'multipart' => $ multipart ] ; } return [ 'form_params' => $ data ] ; }
Prepare request params for POST request, convert to multipart when needed

@param array $data

@return array
Prepare request params for POST request convert to multipart when needed