Skip to content

Commit adcaa2c

Browse files
committed
Fix bug when Create is called with an stdClass body
1 parent 7b87954 commit adcaa2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Elasticsearch/Endpoints/Indices/Create.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class Create extends AbstractEndpoint
1818
{
1919
/**
20-
* @param array $body
20+
* @param array|object $body
2121
*
2222
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
2323
* @return $this
@@ -71,10 +71,11 @@ protected function getParamWhitelist()
7171
*/
7272
protected function getMethod()
7373
{
74-
if (isset($this->body['mappings']) === true) {
74+
if (is_array($this->body) && isset($this->body['mappings']) === true) {
75+
return 'POST';
76+
} elseif (is_object($this->body) && isset($this->body->mappings) === true) {
7577
return 'POST';
76-
} else {
77-
return 'PUT';
7878
}
79+
return 'PUT';
7980
}
8081
}

0 commit comments

Comments
 (0)