Skip to content

Commit 02b13ff

Browse files
committed
Added collection functions to AggregationCollection
1 parent b2c3bf2 commit 02b13ff

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Aggregation/AggregationCollection.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,34 @@ public function filter() : \Spameri\ElasticQuery\Filter\FilterCollection
4343
}
4444

4545

46+
public function add(
47+
LeafAggregationInterface $leafAggregation
48+
) : void
49+
{
50+
$this->aggregations[$leafAggregation->key()] = $leafAggregation;
51+
}
52+
53+
54+
public function keys() : array
55+
{
56+
return \array_map('\strval', \array_keys($this->aggregations));
57+
}
58+
59+
60+
public function isKey(
61+
string $key
62+
) : bool
63+
{
64+
return \array_key_exists($key, \array_map('\strval', \array_keys($this->aggregations)));
65+
}
66+
67+
68+
public function count() : int
69+
{
70+
return \count($this->aggregations);
71+
}
72+
73+
4674
public function toArray() : array
4775
{
4876
$array = [];

0 commit comments

Comments
 (0)