Code Duplication    Length = 47-48 lines in 3 locations

lib/Elastica/Script/Script.php 1 location

@@ 13-60 (lines=48) @@
10
 *
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
12
 */
13
class Script extends AbstractScript
14
{
15
    /**
16
     * @var string
17
     */
18
    private $_scriptCode;
19
20
    /**
21
     * @param string      $scriptCode Script source code
22
     * @param array|null  $params
23
     * @param string|null $lang
24
     * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context)
25
     */
26
    public function __construct($scriptCode, array $params = null, $lang = null, $documentId = null)
27
    {
28
        parent::__construct($params, $lang, $documentId);
29
30
        $this->setScript($scriptCode);
31
    }
32
33
    /**
34
     * @param string $scriptCode
35
     *
36
     * @return $this
37
     */
38
    public function setScript($scriptCode)
39
    {
40
        $this->_scriptCode = $scriptCode;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getScript()
49
    {
50
        return $this->_scriptCode;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function getScriptTypeArray()
57
    {
58
        return ['inline' => $this->_scriptCode];
59
    }
60
}
61

lib/Elastica/Script/ScriptFile.php 1 location

@@ 14-60 (lines=47) @@
11
 *
12
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
13
 */
14
class ScriptFile extends AbstractScript
15
{
16
    /**
17
     * @var string
18
     */
19
    private $_scriptFile;
20
21
    /**
22
     * @param string      $scriptFile Script file name
23
     * @param array|null  $params
24
     * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context)
25
     */
26
    public function __construct($scriptFile, array $params = null, $documentId = null)
27
    {
28
        parent::__construct($params, null, $documentId);
29
30
        $this->setScriptFile($scriptFile);
31
    }
32
33
    /**
34
     * @param string $scriptFile
35
     *
36
     * @return $this
37
     */
38
    public function setScriptFile($scriptFile)
39
    {
40
        $this->_scriptFile = $scriptFile;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return string
47
     */
48
    public function getScriptFile()
49
    {
50
        return $this->_scriptFile;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function getScriptTypeArray()
57
    {
58
        return ['file' => $this->_scriptFile];
59
    }
60
}
61

lib/Elastica/Script/ScriptId.php 1 location

@@ 12-59 (lines=48) @@
9
 *
10
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
11
 */
12
class ScriptId extends AbstractScript
13
{
14
    /**
15
     * @var string
16
     */
17
    private $_scriptId;
18
19
    /**
20
     * @param string      $scriptId   Script ID
21
     * @param array|null  $params
22
     * @param string|null $lang
23
     * @param string|null $documentId Document ID the script action should be performed on (only relevant in update context)
24
     */
25
    public function __construct($scriptId, array $params = null, $lang = null, $documentId = null)
26
    {
27
        parent::__construct($params, $lang, $documentId);
28
29
        $this->setScriptId($scriptId);
30
    }
31
32
    /**
33
     * @param string $scriptId
34
     *
35
     * @return $this
36
     */
37
    public function setScriptId($scriptId)
38
    {
39
        $this->_scriptId = $scriptId;
40
41
        return $this;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getScriptId()
48
    {
49
        return $this->_scriptId;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    protected function getScriptTypeArray()
56
    {
57
        return ['id' => $this->_scriptId];
58
    }
59
}
60