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 "geohash_cell" query. |
||
19 | * |
||
20 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-query.html |
||
21 | * @deprecated Use geohash_grid aggregation instead. |
||
22 | */ |
||
23 | View Code Duplication | class GeohashCellQuery implements BuilderInterface |
|
0 ignored issues
–
show
|
|||
24 | { |
||
25 | use ParametersTrait; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $field; |
||
31 | |||
32 | /** |
||
33 | * @var mixed |
||
34 | */ |
||
35 | private $location; |
||
36 | |||
37 | /** |
||
38 | * @param string $field |
||
39 | * @param mixed $location |
||
40 | * @param array $parameters |
||
41 | */ |
||
42 | public function __construct($field, $location, array $parameters = []) |
||
43 | { |
||
44 | $this->field = $field; |
||
45 | $this->location = $location; |
||
46 | |||
47 | $this->setParameters($parameters); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function getType() |
||
54 | { |
||
55 | return 'geohash_cell'; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * {@inheritdoc} |
||
60 | */ |
||
61 | public function toArray() |
||
62 | { |
||
63 | $query = [$this->field => $this->location]; |
||
64 | $output = $this->processArray($query); |
||
65 | |||
66 | return [$this->getType() => $output]; |
||
67 | } |
||
68 | } |
||
69 |
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.