You are here

public function HttpClientCompositeFormatter::__construct in Http Client 7.2

Same name and namespace in other branches
  1. 6.2 includes/HttpClient.inc \HttpClientCompositeFormatter::__construct()

Creates an assymetrical formatter.

Parameters

string|HttpClientFormatter $send: Optional. The formatter to use when sending requests. Accepts one of the HttpClientBaseFormatter::FORMAT_ constants or a HttpClientFormatter object. Defaults to form encoded.

string|HttpClientFormatter $accept: Optional. The formatter to use when parsing responses. Accepts one of the HttpClientBaseFormatter::FORMAT_ constants or a HttpClientFormatter object. Defaults to json.

File

includes/HttpClient.inc, line 428

Class

HttpClientCompositeFormatter
A utility formatter to use for creating assymetrical http client formatters.

Code

public function __construct($send = HttpClientBaseFormatter::FORMAT_FORM, $accept = HttpClientBaseFormatter::FORMAT_JSON) {
  if (is_string($send)) {
    $send = new HttpClientBaseFormatter($send);
  }
  if (is_string($accept)) {
    $accept = new HttpClientBaseFormatter($accept);
  }
  $this->send = $send;
  $this->accept = $accept;
}