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

ScriptId   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 setScriptId() 6 6 1
A getScriptId() 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
 * Stored script referenced by ID.
6
 *
7
 * @author Tobias Schultze <http://tobion.de>
8
 * @author Martin Janser <[email protected]>
9
 *
10
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
11
 */
12 View Code Duplication
class ScriptId 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...
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