2022-08-31 15:32:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Arendsen\FluxQueryBuilder\Functions;
|
|
|
|
|
|
|
|
|
|
use Arendsen\FluxQueryBuilder\Type;
|
|
|
|
|
use Arendsen\FluxQueryBuilder\Type\ArrayType;
|
|
|
|
|
use Arendsen\FluxQueryBuilder\Type\DurationType;
|
|
|
|
|
|
|
|
|
|
class Window extends Base
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var string $every
|
|
|
|
|
*/
|
|
|
|
|
private $every;
|
|
|
|
|
|
|
|
|
|
/**
|
2022-09-01 12:50:08 +00:00
|
|
|
* @var array $options
|
2022-08-31 15:32:13 +00:00
|
|
|
*/
|
2022-09-01 12:50:08 +00:00
|
|
|
private $options;
|
2022-08-31 15:32:13 +00:00
|
|
|
|
2022-09-01 12:50:08 +00:00
|
|
|
public function __construct($every, array $options = []) {
|
2022-08-31 15:32:13 +00:00
|
|
|
$this->every = $every;
|
2022-09-01 12:50:08 +00:00
|
|
|
$this->options = $options;
|
2022-08-31 15:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function __toString()
|
|
|
|
|
{
|
|
|
|
|
$input = new ArrayType(array_filter([
|
|
|
|
|
'every' => new DurationType($this->every),
|
2022-09-01 12:50:08 +00:00
|
|
|
'period' => isset($this->options['period']) ? new DurationType($this->options['period']) : null,
|
|
|
|
|
'offset' => isset($this->options['offset']) ? new DurationType($this->options['offset']) : null,
|
|
|
|
|
'location' => isset($this->options['location']) ? new Type($this->options['location']) : null,
|
|
|
|
|
'timeColumn' => isset($this->options['timeColumn']) ? new Type($this->options['timeColumn']) : null,
|
|
|
|
|
'startColumn' => isset($this->options['startColumn']) ? new Type($this->options['startColumn']) : null,
|
|
|
|
|
'stopColumn' => isset($this->options['stopColumn']) ? new Type($this->options['stopColumn']) : null,
|
|
|
|
|
'createEmpty' => isset($this->options['createEmpty']) && $this->options['createEmpty'] ?
|
|
|
|
|
new Type($this->options['createEmpty']) : null,
|
2022-08-31 15:32:13 +00:00
|
|
|
]));
|
|
|
|
|
return '|> window(' . $input . ') ';
|
|
|
|
|
}
|
|
|
|
|
}
|