PHP Class FactualResponse

This is a refactoring of the Factual Driver by Aaron: https://github.com/Factual/factual-java-driver
Author: Tyler
Mostra file Open project: factual/factual-php-driver Class Usage Examples

Protected Properties

Property Type Description
$json string
$request
$responseCode
$responseHeaders table getting queried
$status string
$tableName
$version

Public Methods

Method Description
__construct ( $apiResponse ) Constructor, parses return values from CURL in factual::request()
getCode ( ) : string Get http status code returned by Factual
getHeaders ( ) : string Get http headers returned by Factual
getJson ( ) : string Get the entire JSON response from Factual
getRawRequest ( ) : string Get url-encoded request string, does not include auth.
getRequest ( ) : string Get url-decoded request string, does not include auth.
getResponseCode ( ) : integer Get HTTP response code
getResponseHeaders ( ) : array Get response headers sent by Factual
getStatus ( ) : string Get the status returned by the Factual API server, e.g. "ok".
getTable ( ) : string Get table name queried
getVersion ( ) : numeric Get the version returned by the Factual API server, e.g. "3".
isEmpty ( ) : boolean Checks whether data was returned by Factual server. True if Factual's response did not include any results records for the query, false otherwise.
size ( ) : integer Gets count of elements returned in this page of result set (not total count)
success ( ) Test for success (200 status return) Note this tests for a successful http call, not a successful program operation
toString ( ) : string Subclasses of FactualResponse must provide access to the original JSON representation of Factual's response. Alias for getJson()

Protected Methods

Method Description
getTableName ( ) : string Gets table name call was made against
parseJSON ( $json ) : array Parses the server response from the API
parseResponse ( $apiResponse ) : void Parses the entire response from cURL, incl metadata

Method Details

__construct() public method

Constructor, parses return values from CURL in factual::request()
public __construct ( $apiResponse )

getCode() public method

Get http status code returned by Factual
public getCode ( ) : string
return string

getHeaders() public method

Get http headers returned by Factual
public getHeaders ( ) : string
return string

getJson() public method

Get the entire JSON response from Factual
public getJson ( ) : string
return string

getRawRequest() public method

Get url-encoded request string, does not include auth.
public getRawRequest ( ) : string
return string

getRequest() public method

Get url-decoded request string, does not include auth.
public getRequest ( ) : string
return string

getResponseCode() public method

Get HTTP response code
public getResponseCode ( ) : integer
return integer

getResponseHeaders() public method

Get response headers sent by Factual
public getResponseHeaders ( ) : array
return array

getStatus() public method

Get the status returned by the Factual API server, e.g. "ok".
public getStatus ( ) : string
return string

getTable() public method

Get table name queried
public getTable ( ) : string
return string

getTableName() protected method

Gets table name call was made against
protected getTableName ( ) : string
return string

getVersion() public method

Get the version returned by the Factual API server, e.g. "3".
public getVersion ( ) : numeric
return numeric

isEmpty() public method

Checks whether data was returned by Factual server. True if Factual's response did not include any results records for the query, false otherwise.
public isEmpty ( ) : boolean
return boolean

parseJSON() protected method

Parses the server response from the API
protected parseJSON ( $json ) : array
return array structured JSON

parseResponse() protected method

Parses the entire response from cURL, incl metadata
protected parseResponse ( $apiResponse ) : void
return void

size() public method

Gets count of elements returned in this page of result set (not total count)
public size ( ) : integer
return integer

success() public method

Test for success (200 status return) Note this tests for a successful http call, not a successful program operation
public success ( )

toString() public method

Subclasses of FactualResponse must provide access to the original JSON representation of Factual's response. Alias for getJson()
public toString ( ) : string
return string

Property Details

$json protected_oe property

string
protected $json

$request protected_oe property

protected $request

$responseCode protected_oe property

protected $responseCode

$responseHeaders protected_oe property

table getting queried
protected $responseHeaders

$status protected_oe property

string
protected $status

$tableName protected_oe property

protected $tableName

$version protected_oe property

protected $version