Skip to content

Commit

Permalink
support DateTimeImmutable
Browse files Browse the repository at this point in the history
  • Loading branch information
smhg committed Mar 1, 2019
1 parent 95ecb8c commit e370cf9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Timespan/Timespan.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace Timespan;

use \DateTime;
use \DateTimeInterface;
use \DateInterval;
use \DatePeriod;

Expand All @@ -10,7 +10,7 @@ class Timespan
public $start;
public $end;

public function __construct(DateTime $start, DateTime $end)
public function __construct(DateTimeInterface $start, DateTimeInterface $end)
{
$this->start = $start;
$this->end = $end;
Expand All @@ -19,10 +19,10 @@ public function __construct(DateTime $start, DateTime $end)
/**
* Check whether timespan contains a date.
* Includes start, excludes end (like PHP's DatePeriod)
* @param DateTime $date
* @param DateTimeInterface $date
* @return boolean
*/
public function contains(DateTime $date)
public function contains(DateTimeInterface $date)
{
return $this->start <= $date && $date < $this->end;
}
Expand Down Expand Up @@ -100,11 +100,11 @@ public function merge(Timespan $span)

/**
* Trim timespan to fit within boundaries
* @param DateTime $start
* @param DateTime $end
* @param DateTimeInterface $start
* @param DateTimeInterface $end
* @return Timespan|null A new, trimmed, timespan or `null` if nothing remains
*/
public function trim(DateTime $start, DateTime $end)
public function trim(DateTimeInterface $start, DateTimeInterface $end)
{
$trimmed = clone $this;

Expand Down

0 comments on commit e370cf9

Please sign in to comment.