public static function create($data) { if ($data instanceof self) { return $data; } if (is_array($data)) { return new self('', $data); } throw new InvalidException('Failed to create document. Invalid data passed.'); }
/** * @param \Elastica\Document|array $data * * @return $this */ public function setUpsert($data) { $document = Document::create($data); $this->_upsert = $document; return $this; }