From 4c82159ae3145fa1c24215627b1ef1e7100438a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Sun, 22 Oct 2023 09:50:33 +0200 Subject: [PATCH] IBX-6827: Allow to add label aggregation ranges --- .../Content/Query/Aggregation/Range.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/contracts/Repository/Values/Content/Query/Aggregation/Range.php b/src/contracts/Repository/Values/Content/Query/Aggregation/Range.php index b5ec1d20b2..1de74dca04 100644 --- a/src/contracts/Repository/Values/Content/Query/Aggregation/Range.php +++ b/src/contracts/Repository/Values/Content/Query/Aggregation/Range.php @@ -27,12 +27,15 @@ final class Range extends ValueObject */ private $to; - public function __construct($from, $to) + private ?string $label; + + public function __construct($from, $to, ?string $label = null) { parent::__construct(); $this->from = $from; $this->to = $to; + $this->label = $label; } public function getFrom() @@ -45,8 +48,27 @@ public function getTo() return $this->to; } + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(?string $label): void + { + $this->label = $label; + } + public function __toString(): string { + if ($this->label !== null) { + return sprintf( + '%s:[%s;%s)', + $this->label, + $this->getRangeValueAsString($this->from), + $this->getRangeValueAsString($this->to) + ); + } + return sprintf( '[%s;%s)', $this->getRangeValueAsString($this->from),