1<?php
2
3namespace Elastica\Script;
4
5/**
6 * Stored script referenced by ID.
7 *
8 * @author Tobias Schultze <http://tobion.de>
9 * @author Martin Janser <martin.janser@liip.ch>
10 *
11 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
12 */
13class ScriptId extends AbstractScript
14{
15    /**
16     * @var string
17     */
18    private $_scriptId;
19
20    /**
21     * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context)
22     */
23    public function __construct(string $scriptId, ?array $params = null, ?string $lang = null, ?string $documentId = null)
24    {
25        parent::__construct($params, $lang, $documentId);
26
27        $this->setScriptId($scriptId);
28    }
29
30    public function setScriptId(string $scriptId): self
31    {
32        $this->_scriptId = $scriptId;
33
34        return $this;
35    }
36
37    public function getScriptId(): string
38    {
39        return $this->_scriptId;
40    }
41
42    /**
43     * {@inheritdoc}
44     */
45    protected function getScriptTypeArray(): array
46    {
47        return ['id' => $this->_scriptId];
48    }
49}
50