toalett-redis-timeseries/src/Protocol/Query/Components/ContainsAggregation.php
2020-12-28 23:32:37 +01:00

28 lines
642 B
PHP

<?php
namespace Toalett\Redis\Timeseries\Protocol\Query\Components;
use Toalett\Redis\Timeseries\Model\Aggregation;
trait ContainsAggregation
{
protected ?Aggregation $aggregation = null;
public function aggregate(Aggregation $aggregation): self
{
$this->aggregation = $aggregation;
return $this;
}
protected function appendAggregation(array $command): array
{
if (!is_null($this->aggregation)) {
$command[] = 'AGGREGATION';
$command[] = $this->aggregation->type;
$command[] = $this->aggregation->timeBucket;
}
return $command;
}
}