PHP Class Essence\Http\Client\Native

Inheritance: implements Essence\Http\Client
Show file Open project: benjamminf/craft-embedded-assets

Protected Properties

Property Type Description
$_defaultCode integer Default HTTP status code.
$_userAgent string User agent.

Public Methods

Method Description
__construct ( integer $defaultCode = 404 ) Constructor.
get ( string $url ) : string Retrieves contents from the given URL.
setUserAgent ( $agent ) {@inheritDoc}

Protected Methods

Method Description
_createContext ( ) : resource Returns a configured HTTP context.
_extractHttpCode ( string $header ) : integer Extracts an HTTP code from the given response header.

Method Details

__construct() public method

Constructor.
public __construct ( integer $defaultCode = 404 )
$defaultCode integer The default HTTP status code to assume if response headers cannot be parsed.

_createContext() protected method

Returns a configured HTTP context.
protected _createContext ( ) : resource
return resource Context.

_extractHttpCode() protected method

Extracts an HTTP code from the given response header.
protected _extractHttpCode ( string $header ) : integer
$header string Reponse header.
return integer HTTP code.

get() public method

Retrieves contents from the given URL.
public get ( string $url ) : string
$url string The URL fo fetch contents from.
return string The fetched contents.

setUserAgent() public method

{@inheritDoc}
public setUserAgent ( $agent )

Property Details

$_defaultCode protected property

Default HTTP status code.
protected int $_defaultCode
return integer

$_userAgent protected property

User agent.
protected string $_userAgent
return string