Code Duplication    Length = 8-8 lines in 2 locations

src/Aggregation/WeightedAvg.php 2 locations

@@ 41-48 (lines=8) @@
38
     *
39
     * @return $this
40
     */
41
    public function setValueScript(string $script)
42
    {
43
        if ($this->hasParam('value') && isset($this->getParam('value')['field'])) {
44
            throw new InvalidException('Weighted Average aggregation with a value mixing field and script is not possible.');
45
        }
46
47
        return $this->setParam('value', ['script' => $script]);
48
    }
49
50
    /**
51
     * Set the weight for this aggregation.
@@ 77-84 (lines=8) @@
74
     *
75
     * @return $this
76
     */
77
    public function setWeightScript(string $script)
78
    {
79
        if ($this->hasParam('weight') && isset($this->getParam('weight')['field'])) {
80
            throw new InvalidException('Weighted Average aggregation with a weight mixing field and script is not possible.');
81
        }
82
83
        return $this->setParam('weight', ['script' => $script]);
84
    }
85
86
    /**
87
     * Set the format for this aggregation.