Completed
Pull Request — master (#117)
by
unknown
06:58 queued 04:19
created

Suggest::setText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchDSL\Suggest;
13
14
use ONGR\ElasticsearchDSL\BuilderInterface;
15
use ONGR\ElasticsearchDSL\ParametersTrait;
16
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
17
18
class Suggest implements BuilderInterface
19
{
20
    use ParametersTrait;
21
22
    /**
23
     * @var string
24
     */
25
    private $name;
26
27
    /**
28
     * @var string
29
     */
30
    private $type;
31
32
    /**
33
     * @var string
34
     */
35
    private $text;
36
37
    /**
38
     * @var string
39
     */
40
    private $field;
41
42
    /**
43
     * TermSuggest constructor.
44
     * @param string $name
45
     * @param string $type
46
     * @param string $text
47
     * @param string $field
48
     * @param array $parameters
49
     */
50
    public function __construct($name, $type, $text, $field, $parameters = [])
51
    {
52
        $this->setName($name);
53
        $this->setType($type);
54
        $this->setText($text);
55
        $this->setField($field);
56
        $this->setParameters($parameters);
57
    }
58
59
    /**
60
     * @param string $name
61
     */
62
    public function setName($name)
63
    {
64
        $this->name = $name;
65
    }
66
67
    /**
68
     * Returns suggest name
69
     *
70
     * @return string
71
     */
72
    public function getName()
73
    {
74
        return $this->name;
75
    }
76
77
    /**
78
     * Returns element type.
79
     *
80
     * @return string
81
     */
82
    public function getType()
83
    {
84
        return $this->type;
85
    }
86
87
    /**
88
     * @param string $type
89
     */
90
    public function setType($type)
91
    {
92
        $this->type = $type;
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getText()
99
    {
100
        return $this->text;
101
    }
102
103
    /**
104
     * @param string $text
105
     */
106
    public function setText($text)
107
    {
108
        $this->text = $text;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getField()
115
    {
116
        return $this->field;
117
    }
118
119
    /**
120
     * @param string $field
121
     */
122
    public function setField($field)
123
    {
124
        $this->field = $field;
125
    }
126
127
    /**
128
     * {@inheritdoc}
129
     */
130
    public function toArray()
131
    {
132
        $output = [
133
            $this->getName() => [
134
                'text' => $this->getText(),
135
                $this->getType() => $this->processArray(['field' => $this->getField()]),
136
            ]
137
        ];
138
139
        return $output;
140
    }
141
}
142