/** * Performs a Twitter search query. * * @param string $query (optional) * @param array|\Traversable|SearchOptions $options (optional) * @throws Exception\InvalidArgumentException If query is not defined neither $query nor $options or * If query is not a string. * @throws Http\Client\Exception\ExceptionInterface * @return mixed */ public function execute($query = null, $options = null) { if (!$options) { $options = $this->getOptions(); } elseif (!$options instanceof SearchOptions) { $options = new SearchOptions($options); } if (is_string($query)) { $options->setQuery($query); } else { if ($query) { throw new Exception\InvalidArgumentException('query must be a string'); } if (!$options->getQuery()) { throw new Exception\InvalidArgumentException('No query defined'); } } $response = $this->restGet('/search.' . $this->responseType, $options->toArray()); switch ($this->responseType) { case 'json': return Json\Json::decode($response->getBody(), Json\Json::TYPE_ARRAY); break; case 'atom': return Feed\Reader\Reader::importString($response->getBody()); break; } return null; }