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\Aggregation\Bucketing; |
||
13 | |||
14 | use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; |
||
15 | use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait; |
||
16 | use ONGR\ElasticsearchDSL\BuilderInterface; |
||
17 | |||
18 | /** |
||
19 | * Class representing AutoDateHistogramAggregation. |
||
20 | * |
||
21 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-autodatehistogram-aggregation.html |
||
22 | */ |
||
23 | class AutoDateHistogramAggregation extends AbstractAggregation |
||
24 | { |
||
25 | use BucketingTrait; |
||
26 | |||
27 | /** |
||
28 | * Inner aggregations container init. |
||
29 | * |
||
30 | * @param string $name |
||
31 | * @param string $field |
||
32 | * @param int $buckets |
||
33 | * @param string $format |
||
34 | */ |
||
35 | public function __construct($name, $field, $buckets = null, $format = null) |
||
36 | { |
||
37 | parent::__construct($name); |
||
38 | |||
39 | $this->setField($field); |
||
40 | |||
41 | if ($buckets) { |
||
0 ignored issues
–
show
|
|||
42 | $this->addParameter('buckets', $buckets); |
||
43 | } |
||
44 | |||
45 | if ($format) { |
||
0 ignored issues
–
show
The expression
$format of type string|null is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
Loading history...
|
|||
46 | $this->addParameter('format', $format); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | public function getArray() |
||
54 | { |
||
55 | $data = array_filter( |
||
56 | [ |
||
57 | 'field' => $this->getField(), |
||
58 | ] |
||
59 | ); |
||
60 | |||
61 | return $data; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | */ |
||
67 | public function getType() |
||
68 | { |
||
69 | return 'auto_date_histogram'; |
||
70 | } |
||
71 | } |
||
72 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: