/** * Constructor. Returns Reponse object. * * @param array $args (optional) */ public function __construct($args = array()) { foreach ($args as $k => $v) { $this->{$k} = $v; } // turn results into objects if ($this->results) { $docs = array(); $doc_fields = array(); foreach ($this->results as $r) { if (!count($doc_fields)) { foreach ($r as $k => $v) { if (!property_exists($k, 'Doc')) { $doc_fields[] = $k; } } } //diag_dump($r); $d = new Doc($r); foreach ($doc_fields as $field) { $d->set_field($field, $r[$field]); } $docs[] = $d; } $this->results = $docs; } }