Skip to content

Commit

Permalink
Fix bug when Create is called with an stdClass body
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Apr 1, 2016
1 parent 7b87954 commit adcaa2c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Elasticsearch/Endpoints/Indices/Create.php
Expand Up @@ -17,7 +17,7 @@
class Create extends AbstractEndpoint
{
/**
* @param array $body
* @param array|object $body
*
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
* @return $this
Expand Down Expand Up @@ -71,10 +71,11 @@ protected function getParamWhitelist()
*/
protected function getMethod()
{
if (isset($this->body['mappings']) === true) {
if (is_array($this->body) && isset($this->body['mappings']) === true) {
return 'POST';
} elseif (is_object($this->body) && isset($this->body->mappings) === true) {
return 'POST';
} else {
return 'PUT';
}
return 'PUT';
}
}

0 comments on commit adcaa2c

Please sign in to comment.