Skip to content

Commit f32b870

Browse files
committed
refactor(result): simplify bucket key assignment
- Streamlined the assignment of bucket key using a variable - Ensured consistent type casting for bucket key
1 parent 521a61d commit f32b870

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/Response/ResultMapper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@ private function mapBucket(
261261
array $bucketArray,
262262
): \Spameri\ElasticQuery\Response\Result\Aggregation\Bucket
263263
{
264+
$bucketKey = $bucketArray['key'] ?? $bucketPosition;
265+
264266
return new \Spameri\ElasticQuery\Response\Result\Aggregation\Bucket(
265-
$bucketArray['key'] ?? (string) $bucketPosition,
266-
$bucketArray['doc_count'],
267+
(string) $bucketKey,
268+
(int) $bucketArray['doc_count'],
267269
\is_int($bucketPosition) ? $bucketPosition : null,
268270
$bucketArray['from'] ?? null,
269271
$bucketArray['to'] ?? null,

0 commit comments

Comments
 (0)