@@ -31,18 +31,6 @@ abstract class AbstractAggregation implements NamedBuilderInterface
31
31
32
32
private ?BuilderBag $ aggregations = null ;
33
33
34
- /**
35
- * Abstract supportsNesting method.
36
- *
37
- * @return bool
38
- */
39
- abstract protected function supportsNesting (): bool ;
40
-
41
- /**
42
- * @return array|\stdClass
43
- */
44
- abstract public function getArray (): array |\stdClass ;
45
-
46
34
/**
47
35
* Inner aggregations container init.
48
36
*
@@ -53,6 +41,14 @@ public function __construct(string $name)
53
41
$ this ->setName ($ name );
54
42
}
55
43
44
+ /**
45
+ * @return string
46
+ */
47
+ public function getField ()
48
+ {
49
+ return $ this ->field ;
50
+ }
51
+
56
52
/**
57
53
* @param string $field
58
54
*
@@ -65,14 +61,6 @@ public function setField($field)
65
61
return $ this ;
66
62
}
67
63
68
- /**
69
- * @return string
70
- */
71
- public function getField ()
72
- {
73
- return $ this ->field ;
74
- }
75
-
76
64
/**
77
65
* Adds a sub-aggregation.
78
66
*
@@ -86,29 +74,25 @@ public function addAggregation(AbstractAggregation $abstractAggregation)
86
74
}
87
75
88
76
$ this ->aggregations ->add ($ abstractAggregation );
89
-
77
+
90
78
return $ this ;
91
79
}
92
80
93
81
/**
94
- * Returns all sub aggregations .
82
+ * Creates BuilderBag new instance .
95
83
*
96
- * @return BuilderBag[]|NamedBuilderInterface[]
84
+ * @return BuilderBag
97
85
*/
98
- public function getAggregations ()
86
+ private function createBuilderBag ()
99
87
{
100
- if ($ this ->aggregations instanceof BuilderBag) {
101
- return $ this ->aggregations ->all ();
102
- } else {
103
- return [];
104
- }
88
+ return new BuilderBag ();
105
89
}
106
90
107
91
/**
108
92
* Returns sub aggregation.
109
93
* @param string $name Aggregation name to return.
110
94
*
111
- * @return AbstractAggregation|NamedBuilderInterface|null
95
+ * @return \ONGR\ElasticsearchDSL\BuilderInterface
112
96
*/
113
97
public function getAggregation ($ name )
114
98
{
@@ -140,6 +124,18 @@ public function toArray(): array|\stdClass
140
124
return $ result ;
141
125
}
142
126
127
+ /**
128
+ * @return array|\stdClass
129
+ */
130
+ abstract public function getArray (): array |\stdClass ;
131
+
132
+ /**
133
+ * Abstract supportsNesting method.
134
+ *
135
+ * @return bool
136
+ */
137
+ abstract protected function supportsNesting (): bool ;
138
+
143
139
/**
144
140
* Process all nested aggregations.
145
141
*
@@ -157,12 +153,16 @@ protected function collectNestedAggregations()
157
153
}
158
154
159
155
/**
160
- * Creates BuilderBag new instance .
156
+ * Returns all sub aggregations .
161
157
*
162
- * @return BuilderBag
158
+ * @return BuilderBag[]|NamedBuilderInterface[]
163
159
*/
164
- private function createBuilderBag ()
160
+ public function getAggregations (): array
165
161
{
166
- return new BuilderBag ();
162
+ if ($ this ->aggregations instanceof BuilderBag) {
163
+ return $ this ->aggregations ->all ();
164
+ } else {
165
+ return [];
166
+ }
167
167
}
168
168
}
0 commit comments