These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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\Query; |
||
13 | |||
14 | use ONGR\ElasticsearchDSL\BuilderInterface; |
||
15 | use ONGR\ElasticsearchDSL\ParametersTrait; |
||
16 | |||
17 | /** |
||
18 | * Represents Elasticsearch "wildcard" query. |
||
19 | * |
||
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html |
||
21 | */ |
||
22 | View Code Duplication | class WildcardQuery implements BuilderInterface |
|
0 ignored issues
–
show
|
|||
23 | { |
||
24 | use ParametersTrait; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $field; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $value; |
||
35 | |||
36 | /** |
||
37 | * @param string $field |
||
38 | * @param string $value |
||
39 | * @param array $parameters |
||
40 | */ |
||
41 | public function __construct($field, $value, array $parameters = []) |
||
42 | { |
||
43 | $this->field = $field; |
||
44 | $this->value = $value; |
||
45 | $this->setParameters($parameters); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function getType() |
||
52 | { |
||
53 | return 'wildcard'; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * {@inheritdoc} |
||
58 | */ |
||
59 | public function toArray() |
||
60 | { |
||
61 | $query = [ |
||
62 | 'value' => $this->value, |
||
63 | ]; |
||
64 | |||
65 | $output = [ |
||
66 | $this->field => $this->processArray($query), |
||
67 | ]; |
||
68 | |||
69 | return [$this->getType() => $output]; |
||
70 | } |
||
71 | } |
||
72 |
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.