src/Application/HttpClient/HttpService.php
protected function createBodyRequest(
        string $method,
        $uri,
        array $parameters = [],
        ?ContentType $contentType = null,
        array $headers = [],
        string $protocol = '1.1'
    ): RequestInterface {
        if ($contentType === null) {
            $contentType = ContentType::fromValue(ContentType::FORM);
        }

        $body = null;
        if (!empty($parameters)) {
            switch ($contentType->value()) {
                case ContentType::FORM:
                    $body = http_build_query($parameters);
                    break;
                case ContentType::JSON:
                    $body = json_encode($parameters);
                    break;
                default:
                    break;
            }
        }

        if ($body !== null) {
            $headers = array_merge(['Content-Type' => $contentType->value()], $headers);
        }

        $uri = $this->createUri($uri);
        $body = $this->createStream($body);

        return $this->createRequest($method, $uri, $headers, $body, $protocol);
    }
protected function createBodyRequest(
        string $method,
        $uri,
        array $parameters = [],
        ?ContentType $contentType = null,
        array $headers = [],
        string $protocol = '1.1'
    ): RequestInterface {
        if ($contentType === null) {
            $contentType = ContentType::fromValue(ContentType::FORM);
        }

        $body = null;
        if (!empty($parameters)) {
            switch ($contentType->value()) {
                case ContentType::FORM:
                    $body = http_build_query($parameters);
                    break;
                case ContentType::JSON:
                    $body = json_encode($parameters);
                    break;
                default:
                    break;
            }
        }

        if ($body !== null) {
            $headers = array_merge(['Content-Type' => $contentType->value()], $headers);
        }

        $uri = $this->createUri($uri);
        $body = $this->createStream($body);

        return $this->createRequest($method, $uri, $headers, $body, $protocol);
    }
protected function createBodyRequest ( string $ method , $ uri , array $ parameters = [ ] , ? ContentType $ contentType = null , array $ headers = [ ] , string $ protocol = '1.1' ) : RequestInterface { if ( $ contentType === null ) { $ contentType = ContentType :: fromValue ( ContentType :: FORM ) ; } $ body = null ; if ( ! empty ( $ parameters ) ) { switch ( $ contentType -> value ( ) ) { case ContentType :: FORM : $ body = http_build_query ( $ parameters ) ; break ; case ContentType :: JSON : $ body = json_encode ( $ parameters ) ; break ; default : break ; } } if ( $ body !== null ) { $ headers = array_merge ( [ 'Content-Type' => $ contentType -> value ( ) ] , $ headers ) ; } $ uri = $ this -> createUri ( $ uri ) ; $ body = $ this -> createStream ( $ body ) ; return $ this -> createRequest ( $ method , $ uri , $ headers , $ body , $ protocol ) ; }
Creates a body request

@param string              $method      Request method
@param string|UriInterface $uri         Request URI
@param array               $parameters  Body parameters
@param ContentType|null    $contentType The content type
@param array               $headers     Request headers
@param string              $protocol    Protocol version

@return RequestInterface
Creates a body request