Add DateTime required param for Range functions
Signed-off-by: davidarendsen <davidarendsen@hey.com>
This commit is contained in:
parent
15a3f8fcde
commit
95e71624d5
5 changed files with 33 additions and 51 deletions
|
|
@ -18,10 +18,10 @@ class Range extends Base {
|
|||
*/
|
||||
private $stop;
|
||||
|
||||
public function __construct(array $settings)
|
||||
public function __construct(DateTime $start, ?DateTime $stop = null)
|
||||
{
|
||||
$this->start = isset($settings['start']) ? $settings['start'] : null;
|
||||
$this->stop = isset($settings['stop']) ? $settings['stop'] : null;
|
||||
$this->start = Formatters::dateTimeToString($start);
|
||||
$this->stop = $stop ? Formatters::dateTimeToString($stop) : null;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
|
|
@ -31,16 +31,6 @@ class Range extends Base {
|
|||
throw new FunctionRequiredSettingMissingException('Range', 'Start setting is required!');
|
||||
}
|
||||
|
||||
if($this->start instanceof DateTime)
|
||||
{
|
||||
$this->start = Formatters::dateTimeToString($this->start);
|
||||
}
|
||||
|
||||
if($this->stop instanceof DateTime)
|
||||
{
|
||||
$this->stop = Formatters::dateTimeToString($this->stop);
|
||||
}
|
||||
|
||||
$settingsString = 'start: ' . $this->start;
|
||||
if($this->stop)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -91,32 +91,25 @@ class QueryBuilder {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function addRange(array $range): QueryBuilder
|
||||
public function addRange(DateTime $start, ?DateTime $stop = null): QueryBuilder
|
||||
{
|
||||
$this->addRequiredData(self::REQUIRED_INPUT_RANGE, $range);
|
||||
$this->addRequiredData(self::REQUIRED_INPUT_RANGE, [$start, $stop]);
|
||||
$this->addToQuery(
|
||||
self::FLUX_PART_RANGE,
|
||||
new Range($range)
|
||||
new Range($start, $stop)
|
||||
);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|DateTime $rangeStart
|
||||
*/
|
||||
public function addRangeStart($rangeStart): QueryBuilder
|
||||
public function addRangeStart(DateTime $start): QueryBuilder
|
||||
{
|
||||
$this->addRange(['start' => $rangeStart]);
|
||||
$this->addRange($start);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|DateTime $start
|
||||
* @param string|DateTime $stop
|
||||
*/
|
||||
public function addRangeInBetween($start, $stop)
|
||||
public function addRangeInBetween(DateTime $start, DateTime $stop)
|
||||
{
|
||||
$this->addRange(['start' => $start, 'stop' => $stop]);
|
||||
$this->addRange($start, $stop);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue