PHP Class Ixudra\Curl\Builder

Afficher le fichier Open project: ixudra/curl

Protected Properties

Свойство Type Description
$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

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
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

Method Details

allowRedirect() public méthode

Allow for redirects in the request
public allowRedirect ( ) : Builder
Résultat Builder

appendDataToURL() protected méthode

Append set data to the query string for GET and DELETE cURL requests
protected appendDataToURL ( ) : string
Résultat string

asJson() public méthode

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
Résultat Builder

asJsonRequest() public méthode

Configure the package to encode the request data to json before sending it to the server
public asJsonRequest ( ) : Builder
Résultat Builder

asJsonResponse() public méthode

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
Résultat Builder

containsFile() public méthode

Enable File sending
public containsFile ( ) : Builder
Résultat Builder

delete() public méthode

Send a DELETE request to a URL using the specified cURL options
public delete ( ) : mixed
Résultat mixed

download() public méthode

Send a download request to a URL using the specified cURL options
public download ( string $fileName ) : mixed
$fileName string
Résultat mixed

enableDebug() public méthode

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
Résultat Builder

forgeOptions() protected méthode

Convert the curlOptions to an array of usable options for the cURL request
protected forgeOptions ( ) : array
Résultat array

get() public méthode

Send a GET request to a URL using the specified cURL options
public get ( ) : mixed
Résultat mixed

patch() public méthode

Send a PATCH request to a URL using the specified cURL options
public patch ( ) : mixed
Résultat mixed

post() public méthode

Send a POST request to a URL using the specified cURL options
public post ( ) : mixed
Résultat mixed

put() public méthode

Send a PUT request to a URL using the specified cURL options
public put ( ) : mixed
Résultat mixed

returnResponse() protected méthode

protected returnResponse ( mixed $content, array $responseData = [] ) : stdClas\stdClass
$content mixed Content of the request
$responseData array Additional response information
Résultat stdClas\stdClass

returnResponseObject() public méthode

Return a full response object with HTTP status and headers instead of only the content
public returnResponseObject ( ) : Builder
Résultat Builder

send() protected méthode

Send the request
protected send ( ) : mixed
Résultat mixed

setPostParameters() protected méthode

Add POST parameters to the curlOptions array
protected setPostParameters ( )

to() public méthode

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
Résultat Builder

withContentType() public méthode

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
Résultat Builder

withCurlOption() protected méthode

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
Résultat Builder

withData() public méthode

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
Résultat Builder

withHeader() public méthode

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
Résultat Builder

withHeaders() public méthode

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
Résultat Builder

withOption() public méthode

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
Résultat Builder

withPackageOption() protected méthode

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
Résultat Builder

withTimeout() public méthode

Set the request timeout
public withTimeout ( integer $timeout = 30 ) : Builder
$timeout integer The timeout for the request (in seconds. Default: 30 seconds)
Résultat Builder

Property Details

$curlObject protected_oe property

cURL request
protected resource $curlObject
Résultat resource

$curlOptions protected_oe property

Array of cURL options
protected array $curlOptions
Résultat array

$packageOptions protected_oe property

Array with options that are not specific to cURL but are used by the package
protected array $packageOptions
Résultat array