1 | <?php |
||
42 | class QueryContent implements JsonSerializable { |
||
43 | |||
44 | |||
45 | const OPTION_MUST = 1; |
||
46 | const OPTION_MUST_NOT = 2; |
||
47 | |||
48 | |||
49 | /** @var string */ |
||
50 | private $word; |
||
51 | |||
52 | /** @var string */ |
||
53 | private $should; |
||
54 | |||
55 | /** @var string */ |
||
56 | private $match; |
||
57 | |||
58 | /** @var int */ |
||
59 | private $option = 0; |
||
60 | |||
61 | |||
62 | /** @var array */ |
||
63 | private $options = [ |
||
64 | '+' => [self::OPTION_MUST, 'must', 'match_phrase_prefix'], |
||
65 | '-' => [self::OPTION_MUST_NOT, 'must_not', 'match_phrase_prefix'] |
||
66 | ]; |
||
67 | |||
68 | |||
69 | /** |
||
70 | * QueryContent constructor. |
||
71 | * |
||
72 | * @param string $word |
||
73 | */ |
||
74 | function __construct(string $word) { |
||
79 | |||
80 | |||
81 | /** |
||
82 | * |
||
83 | */ |
||
84 | private function init() { |
||
106 | |||
107 | |||
108 | /** |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getWord(): string { |
||
114 | |||
115 | /** |
||
116 | * @param string $word |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | public function setWord(string $word): QueryContent { |
||
125 | |||
126 | |||
127 | /** |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getShould(): string { |
||
133 | |||
134 | /** |
||
135 | * @param string $should |
||
136 | * |
||
137 | * @return QueryContent |
||
138 | */ |
||
139 | public function setShould(string $should): QueryContent { |
||
144 | |||
145 | |||
146 | /** |
||
147 | * @return string |
||
148 | */ |
||
149 | public function getMatch(): string { |
||
152 | |||
153 | /** |
||
154 | * @param string $match |
||
155 | * |
||
156 | * @return QueryContent |
||
157 | */ |
||
158 | public function setMatch(string $match): QueryContent { |
||
163 | |||
164 | |||
165 | /** |
||
166 | * @return int |
||
167 | */ |
||
168 | public function getOption(): int { |
||
171 | |||
172 | /** |
||
173 | * @param int $option |
||
174 | * |
||
175 | * @return QueryContent |
||
176 | */ |
||
177 | public function setOption(int $option): QueryContent { |
||
182 | |||
183 | |||
184 | /** |
||
185 | * @return array |
||
186 | */ |
||
187 | public function jsonSerialize(): array { |
||
195 | |||
196 | } |
||
197 | |||
198 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.