Code Duplication    Length = 68-68 lines in 2 locations

src/Aggregation/Bucketing/DiversifiedSamplerAggregation.php 1 location

@@ 22-89 (lines=68) @@
19
 *
20
 * @link https://goo.gl/yzXvqD
21
 */
22
class DiversifiedSamplerAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * Defines how many results will be received from each shard
28
     * @param integer $shardSize
29
     */
30
    private $shardSize;
31
32
    /**
33
     * DiversifiedSamplerAggregation constructor.
34
     *
35
     * @param string $name Aggregation name
36
     * @param string $field Elasticsearch field name
37
     * @param int $shardSize Shard size, by default it's 100
38
     */
39
    public function __construct($name, $field = null, $shardSize = null)
40
    {
41
        parent::__construct($name);
42
43
        $this->setField($field);
44
        $this->setShardSize($shardSize);
45
    }
46
47
    /**
48
     * @return mixed
49
     */
50
    public function getShardSize()
51
    {
52
        return $this->shardSize;
53
    }
54
55
    /**
56
     * @param mixed $shardSize
57
     *
58
     * @return $this
59
     */
60
    public function setShardSize($shardSize)
61
    {
62
        $this->shardSize = $shardSize;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function getType()
71
    {
72
        return 'diversified_sampler';
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78
    protected function getArray()
79
    {
80
        $out = array_filter(
81
            [
82
                'field' => $this->getField(),
83
                'shard_size' => $this->getShardSize(),
84
            ]
85
        );
86
87
        return $out;
88
    }
89
}
90

src/Aggregation/Bucketing/SamplerAggregation.php 1 location

@@ 22-89 (lines=68) @@
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations-bucket-sampler-aggregation.html
21
 */
22
class SamplerAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * Defines how many results will be received from each shard
28
     * @param string $shardSize
29
     */
30
    private $shardSize;
31
32
    /**
33
     * Inner aggregations container init.
34
     *
35
     * @param string $name
36
     * @param string $field
37
     * @param int    $shardSize
38
     */
39
    public function __construct($name, $field = null, $shardSize = null)
40
    {
41
        parent::__construct($name);
42
43
        $this->setField($field);
44
        $this->setShardSize($shardSize);
45
    }
46
47
    /**
48
     * @return int
49
     */
50
    public function getShardSize()
51
    {
52
        return $this->shardSize;
53
    }
54
55
    /**
56
     * @param int $shardSize
57
     *
58
     * @return $this
59
     */
60
    public function setShardSize($shardSize)
61
    {
62
        $this->shardSize = $shardSize;
63
64
        return $this;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getType()
71
    {
72
        return 'sampler';
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function getArray()
79
    {
80
        $out = array_filter(
81
            [
82
                'field' => $this->getField(),
83
                'shard_size' => $this->getShardSize(),
84
            ]
85
        );
86
87
        return $out;
88
    }
89
}
90