1<?php 2 3namespace Basho\Riak\Command\Indexes; 4 5 6/** 7 * Container for a response related to an index query 8 * 9 * @author Alex Moore <amoore at basho d0t com> 10 */ 11class Response extends \Basho\Riak\Command\Response 12{ 13 /** 14 * @var array 15 */ 16 protected $results = []; 17 18 /** 19 * @var bool 20 */ 21 protected $termsReturned = false; 22 23 protected $done = false; 24 25 /** 26 * @var string|null 27 */ 28 protected $continuation = null; 29 30 protected $date = ''; 31 32 public function __construct($success = true, $code = 0, $message = '', $results = [], $termsReturned = false, $continuation = null, $done = true, $date = '') 33 { 34 parent::__construct($success, $code, $message); 35 36 $this->results = $results; 37 $this->termsReturned = $termsReturned; 38 $this->continuation = $continuation; 39 $this->done = $done; 40 $this->date = $date; 41 42 // when timeout is used, cURL returns success for some reason 43 if (in_array($code, ['501', '503'])) { 44 $this->success = false; 45 } 46 } 47 48 /** 49 * Get the array of keys that match the query 50 * 51 * @return array 52 */ 53 public function getResults() 54 { 55 return $this->results; 56 } 57 58 /** 59 * Indicates whether the terms are included in the results array. 60 * 61 * @return bool 62 */ 63 public function hasReturnTerms() 64 { 65 return $this->termsReturned; 66 } 67 68 /** 69 * Get the continuation string for paged queries. 70 * 71 * @return null|string 72 */ 73 public function getContinuation() 74 { 75 return $this->continuation; 76 } 77 78 /** 79 * Retrieves the date of the counter's retrieval 80 * 81 * @return string 82 * @throws \Basho\Riak\Command\Exception 83 */ 84 public function getDate() 85 { 86 return $this->date; 87 } 88 89 public function isDone() 90 { 91 return $this->done; 92 } 93} 94