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

Script   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 48
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A setScript() 6 6 1
A getScript() 4 4 1
A getScriptTypeArray() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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