Completed
Push — master ( 96ab8a...466607 )
by Nicolas
03:10
created

Script::create()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.2
cc 4
eloc 8
nc 4
nop 1
1
<?php
2
namespace Elastica\Script;
3
4
/**
5
 * Inline script.
6
 *
7
 * @author avasilenko <[email protected]>
8
 * @author Tobias Schultze <http://tobion.de>
9
 * @author Martin Janser <[email protected]>
10
 *
11
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
12
 */
13 View Code Duplication
class Script extends AbstractScript
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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