PHP Класс Ixudra\Curl\Builder

Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$curlObject resource cURL request
$curlOptions array Array of cURL options
$packageOptions array Array with options that are not specific to cURL but are used by the package

Открытые методы

Метод Описание
allowRedirect ( ) : Builder Allow for redirects in the request
asJson ( boolean $asArray = false ) : Builder Configure the package to encode and decode the request data
asJsonRequest ( ) : Builder Configure the package to encode the request data to json before sending it to the server
asJsonResponse ( boolean $asArray = false ) : Builder Configure the package to decode the request data from json to object or associative array
containsFile ( ) : Builder Enable File sending
delete ( ) : mixed Send a DELETE request to a URL using the specified cURL options
download ( string $fileName ) : mixed Send a download request to a URL using the specified cURL options
enableDebug ( string $logFile ) : Builder Enable debug mode for the cURL request
get ( ) : mixed Send a GET request to a URL using the specified cURL options
patch ( ) : mixed Send a PATCH request to a URL using the specified cURL options
post ( ) : mixed Send a POST request to a URL using the specified cURL options
put ( ) : mixed Send a PUT request to a URL using the specified cURL options
returnResponseObject ( ) : Builder Return a full response object with HTTP status and headers instead of only the content
to ( $url ) : Builder Set the URL to which the request is to be sent
withContentType ( string $contentType ) : Builder Add a content type HTTP header to the request
withData ( array $data = [] ) : Builder Add GET or POST data to the request
withHeader ( string $header ) : Builder Add a HTTP header to the request
withHeaders ( array $headers ) : Builder Add multiple HTTP header at the same time to the request
withOption ( string $key, string $value ) : Builder Set any specific cURL option
withTimeout ( integer $timeout = 30 ) : Builder Set the request timeout

Защищенные методы

Метод Описание
appendDataToURL ( ) : string Append set data to the query string for GET and DELETE cURL requests
forgeOptions ( ) : array Convert the curlOptions to an array of usable options for the cURL request
returnResponse ( mixed $content, array $responseData = [] ) : stdClas\stdClass
send ( ) : mixed Send the request
setPostParameters ( ) Add POST parameters to the curlOptions array
withCurlOption ( string $key, string $value ) : Builder Set any specific cURL option
withPackageOption ( string $key, string $value ) : Builder Set any specific package option

Описание методов

allowRedirect() публичный Метод

Allow for redirects in the request
public allowRedirect ( ) : Builder
Результат Builder

appendDataToURL() защищенный Метод

Append set data to the query string for GET and DELETE cURL requests
protected appendDataToURL ( ) : string
Результат string

asJson() публичный Метод

Configure the package to encode and decode the request data
public asJson ( boolean $asArray = false ) : Builder
$asArray boolean Indicates whether or not the data should be returned as an array. Default: false
Результат Builder

asJsonRequest() публичный Метод

Configure the package to encode the request data to json before sending it to the server
public asJsonRequest ( ) : Builder
Результат Builder

asJsonResponse() публичный Метод

Configure the package to decode the request data from json to object or associative array
public asJsonResponse ( boolean $asArray = false ) : Builder
$asArray boolean Indicates whether or not the data should be returned as an array. Default: false
Результат Builder

containsFile() публичный Метод

Enable File sending
public containsFile ( ) : Builder
Результат Builder

delete() публичный Метод

Send a DELETE request to a URL using the specified cURL options
public delete ( ) : mixed
Результат mixed

download() публичный Метод

Send a download request to a URL using the specified cURL options
public download ( string $fileName ) : mixed
$fileName string
Результат mixed

enableDebug() публичный Метод

Enable debug mode for the cURL request
public enableDebug ( string $logFile ) : Builder
$logFile string The full path to the log file you want to use
Результат Builder

forgeOptions() защищенный Метод

Convert the curlOptions to an array of usable options for the cURL request
protected forgeOptions ( ) : array
Результат array

get() публичный Метод

Send a GET request to a URL using the specified cURL options
public get ( ) : mixed
Результат mixed

patch() публичный Метод

Send a PATCH request to a URL using the specified cURL options
public patch ( ) : mixed
Результат mixed

post() публичный Метод

Send a POST request to a URL using the specified cURL options
public post ( ) : mixed
Результат mixed

put() публичный Метод

Send a PUT request to a URL using the specified cURL options
public put ( ) : mixed
Результат mixed

returnResponse() защищенный Метод

protected returnResponse ( mixed $content, array $responseData = [] ) : stdClas\stdClass
$content mixed Content of the request
$responseData array Additional response information
Результат stdClas\stdClass

returnResponseObject() публичный Метод

Return a full response object with HTTP status and headers instead of only the content
public returnResponseObject ( ) : Builder
Результат Builder

send() защищенный Метод

Send the request
protected send ( ) : mixed
Результат mixed

setPostParameters() защищенный Метод

Add POST parameters to the curlOptions array
protected setPostParameters ( )

to() публичный Метод

Set the URL to which the request is to be sent
public to ( $url ) : Builder
$url string The URL to which the request is to be sent
Результат Builder

withContentType() публичный Метод

Add a content type HTTP header to the request
public withContentType ( string $contentType ) : Builder
$contentType string The content type of the file you would like to download
Результат Builder

withCurlOption() защищенный Метод

Set any specific cURL option
protected withCurlOption ( string $key, string $value ) : Builder
$key string The name of the cURL option
$value string The value to which the option is to be set
Результат Builder

withData() публичный Метод

Add GET or POST data to the request
public withData ( array $data = [] ) : Builder
$data array Array of data that is to be sent along with the request
Результат Builder

withHeader() публичный Метод

Add a HTTP header to the request
public withHeader ( string $header ) : Builder
$header string The HTTP header that is to be added to the request
Результат Builder

withHeaders() публичный Метод

Add multiple HTTP header at the same time to the request
public withHeaders ( array $headers ) : Builder
$headers array Array of HTTP headers that must be added to the request
Результат Builder

withOption() публичный Метод

Set any specific cURL option
public withOption ( string $key, string $value ) : Builder
$key string The name of the cURL option
$value string The value to which the option is to be set
Результат Builder

withPackageOption() защищенный Метод

Set any specific package option
protected withPackageOption ( string $key, string $value ) : Builder
$key string The name of the cURL option
$value string The value to which the option is to be set
Результат Builder

withTimeout() публичный Метод

Set the request timeout
public withTimeout ( integer $timeout = 30 ) : Builder
$timeout integer The timeout for the request (in seconds. Default: 30 seconds)
Результат Builder

Описание свойств

$curlObject защищенное свойство

cURL request
protected resource $curlObject
Результат resource

$curlOptions защищенное свойство

Array of cURL options
protected array $curlOptions
Результат array

$packageOptions защищенное свойство

Array with options that are not specific to cURL but are used by the package
protected array $packageOptions
Результат array