Adds addRangeFrom() method.

This commit is contained in:
Pierre Lannoy 2024-03-30 17:41:40 +01:00
commit 71bca9f1b1
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31
4 changed files with 52 additions and 7 deletions

View file

@ -57,7 +57,7 @@ trait Basics {
return $this;
}
public function addRange( DateTime $start, ?DateTime $stop = null ): QueryBuilderInterface {
public function addRange( mixed $start, ?DateTime $stop = null ): QueryBuilderInterface {
$this->setRequirements();
$this->addToQuery(
@ -73,6 +73,12 @@ trait Basics {
return $this;
}
public function addRangeFrom( string $from ): QueryBuilderInterface {
$this->addRange( $from );
return $this;
}
public function addRangeInBetween( DateTime $start, DateTime $stop ): QueryBuilderInterface {
$this->addRange( $start, $stop );

View file

@ -17,7 +17,7 @@ class Range extends Base {
*/
private $stop;
public function __construct( DateTime $start, ?DateTime $stop = null ) {
public function __construct( mixed $start, ?DateTime $stop = null ) {
$this->start = new Type( $start );
$this->stop = $stop ? new Type( $stop ) : null;
}
@ -27,7 +27,7 @@ class Range extends Base {
throw new FunctionRequiredSettingMissingException( 'Range', 'Start setting is required!' );
}
$settingsString = 'start: ' . $this->start;
$settingsString = str_replace( '"', '', 'start: ' . $this->start );
if ( $this->stop ) {
$settingsString .= ', stop: ' . $this->stop;
}